private void ProjectInstaller_AfterInstall(object sender, InstallEventArgs e)
{
try
{
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 = "Net Start Service1"; //CMD命令
string Cmdstring = "sc config " + serviceInstaller1.ServiceName + " type= interact type= own";
p.StandardInput.WriteLine(Cmdstring);
Cmdstring = "sc start " + serviceInstaller1.ServiceName;
p.StandardInput.WriteLine(Cmdstring);
p.StandardInput.WriteLine("exit");
}
catch
{ }
}
{
try
{
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 = "Net Start Service1"; //CMD命令
string Cmdstring = "sc config " + serviceInstaller1.ServiceName + " type= interact type= own";
p.StandardInput.WriteLine(Cmdstring);
Cmdstring = "sc start " + serviceInstaller1.ServiceName;
p.StandardInput.WriteLine(Cmdstring);
p.StandardInput.WriteLine("exit");
}
catch
{ }
}
本文转自94cool博客园博客,原文链接:http://www.cnblogs.com/94cool/archive/2010/04/12/1710289.html,如需转载请自行联系原作者