string[] cmdline = { }; /*E:\test\WindowsServiceTest\MyWeb\bin*/ string path = Server.MapPath("/bin/"); string s = Server.MapPath("/bin/WindowsServiceTest.exe"); //AssemblyInstaller installer = new AssemblyInstaller(); //installer.Path = Server.MapPath("/bin/WindowsServiceTest.exe"); //installer.UseNewContext = true; //installer.Install(null); //installer.Commit(null); //installer.Dispose(); #region //TransactedInstaller transactedInstaller = new TransactedInstaller(); //AssemblyInstaller assemblyInstaller = new AssemblyInstaller(@"E:\test\WindowsServiceTest\MyWeb\bin\WindowsServiceTest.exe", cmdline); //transactedInstaller.Installers.Add(assemblyInstaller); //transactedInstaller.Install(new System.Collections.Hashtable()); #endregion #region ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = "cmd.exe"; startInfo.Arguments = "/c C:\\Windows\\System32\\cmd.exe"; startInfo.RedirectStandardInput = true; startInfo.RedirectStandardOutput = true; startInfo.RedirectStandardError = true; startInfo.UseShellExecute = false; startInfo.Verb = "RunAs"; Process p = new Process(); p.StartInfo = startInfo; p.Start(); // 启动进程 //p.StandardInput.WriteLine(@"del D:\123.txt"); // Cmd 命令 p.StandardInput.WriteLine(@"e:"); // Cmd 命令 p.StandardInput.WriteLine(@"cd E:\test\WindowsServiceTest\WindowsServiceTest\bin\Debug"); // Cmd 命令 p.StandardInput.WriteLine(@"installutil WindowsServiceTest.exe"); // Cmd 命令 p.StandardInput.WriteLine("exit"); // 退出 #endregion
时间: 2024-12-15 01:26:33