ASP.NET启动Windows服务
protected void Button1_Click(object sender, EventArgs e)
{
string service_start_string = "net start wscsvc";
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;
string strOutput = null;
try
{
p.Start();
p.StandardInput.WriteLine(service_start_string );
p.StandardInput.WriteLine("exit");
strOutput = p.StandardOutput.ReadToEnd();
p.WaitForExit();
p.Close();
}
catch (Exception e)
{
strOutput = e.Message;
}
}
在本地打开网页的时候,可以启动wscsvc服务(Security Center)。但如果在其他机器上就不能启动,而且也不报错。
是什么原因?