Exemple #1
0
        public Program(string[] args)
        {
            Console.Title = "安装IIS";
            IntPtr ParenthWnd = new IntPtr(0);
            IntPtr et         = new IntPtr(0);

            ParenthWnd = FindWindow(null, "安装IIS");
            ShowWindow(ParenthWnd, 0);//隐藏本dos窗体, 0: 后台执行;1:正常启动;2:最小化到任务栏;3:最大化

            //作自己的事情
            IIISInstaller installer = IISManagerFactory.New().CreateIISInstaller();

            if (args.Length >= 1 && args[0] == "-u") //卸载
            {
                if (!installer.IsFullyInstalled())
                {
                    installer.UninstallIIS();
                }
            }
            else
            {
                System.Console.WriteLine("正在安装IIS,请稍候...");
                if (!installer.IsFullyInstalled())
                {
                    installer.InstallIIS();
                }
            }

            Console.Write("Exit");
        }
 public override void Excute()
 {
     if (System.Environment.Is64BitProcess)
     {
         IIISInstaller installer = IISManagerFactory.New().CreateIISInstaller();
         if (!installer.IsFullyInstalled())
         {
             installer.InstallIIS();
         }
     }
     else
     {
         var proc = new Process();
         proc.StartInfo.FileName         = Path.Combine(System.Environment.CurrentDirectory, "Install4IIS.exe");
         proc.StartInfo.WorkingDirectory = System.Environment.CurrentDirectory;
         // proc.StartInfo.Arguments = string.Format("10");//this is argument
         proc.StartInfo.CreateNoWindow  = false;
         proc.StartInfo.UseShellExecute = true;
         proc.Start();
         proc.WaitForExit();
     }
 }