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)。但如果在其他机器上就不能启动,而且也不报错。
是什么原因?

解决方案 »

  1.   

    IIS里开启了WINDOWS身份验证,
    而你以系统管理员的身份(或者有权限开启这个服务的系统帐号)登录了系统这样,你本地访问网站的时候,网站是以系统管理员的身份(或者有权限开启这个服务的系统帐号)来运行的,当然有权限运行了.非本地机,网站是以IIS中设置的匿名用户身份来运行的,这个账户无权启动服务.这是很正常的,只要服务器权限设置得当,不用担心存在安全问题