标签:file cmd start 服务安装 tty tin installer lex win
置serviceProcessInstaller1控件的Account属性为“LocalSystem”
设置serviceInstaller1控件的StartType属性为"Automatic"
在private void ProjectInstaller_AfterInstall(object sender, InstallEventArgs e)事件中,添加以下代码:
Process p = new Process(); p.StartInfo.FileName = "cmd.exe"; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardInput = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardError = true; p.StartInfo.CreateNoWindow = true; p.Start(); string cmdstring = "sc start yourservicename"; //CMD命令 p.StandardInput.WriteLine(cmdstring); p.StandardInput.WriteLine("exit");
标签:file cmd start 服务安装 tty tin installer lex win
原文地址:http://www.cnblogs.com/glzgc/p/7940539.html