0

我正在尝试暂时停止“程序兼容性助手服务”。但是下面的代码给出了错误“无法在计算机'.'上打开 PcaSvc 服务”。我使用“PcaSvc”和“程序兼容性助手服务”作为名称,但它们都给出了相同的错误。并且服务正在运行。有人可以解释一下吗?

ServiceController service = new ServiceController("PcaSvc");
try
{
    service.Stop();
    service.WaitForStatus(ServiceControllerStatus.Stopped);
}
catch (Exception e)
{
    MessageBox.Show(e.Message);
}
4

1 回答 1

1

这可能是一个安全问题。

请参阅:Windows 7 中的 ServiceController 权限

另请参阅: Windows 7 中代码中的停止/启动服务

于 2013-11-12T22:39:39.700 回答