string[] CmdLine = { }; /*E:\test\WindowsServiceTest\MyWeb\bin*/ stringPath = Server.MapPath ("/bin/"); strings = 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 #regionProcessStartInfo StartInfo=NewProcessStartInfo (); 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=NewProcess (); P.startinfo=StartInfo; P.start (); //START Process//p.standardinput.writeline (@ "del D:\123.txt");//CMD CommandP.standardinput.writeline (@"e:");//CMD CommandP.standardinput.writeline (@"CD E:\test\WindowsServiceTest\WindowsServiceTest\bin\Debug");//CMD CommandP.standardinput.writeline (@"InstallUtil WindowsServiceTest.exe");//CMD CommandP.standardinput.writeline ("Exit");//Exit #endregion
Windows Service Installation