2
我在C#中非常新,我收到此錯誤:無法在計算機'ip地址'上打開服務控制管理器。此操作可能需要其他特權
Cannot open Service Control Manager on computer '172.168.1.106'. This operation might require other privileges.
當我嘗試啓動/停止安裝在屬於同一網絡的另一臺計算機服務我的電腦。那麼有沒有人有任何準時的解決方案呢?任何教程?該服務作爲網絡服務安裝在另一臺計算機上。
這是我的代碼看起來(基本部分):
ServiceController servicio = new ServiceController(nombre, "172.168.1.106");
public bool ReiniciarServicio()
{
try
{
if (servicio.Status == ServiceControllerStatus.Running)
{
servicio.Stop();
servicio.WaitForStatus(ServiceControllerStatus.Stopped);
servicio.Start();
servicio.WaitForStatus(ServiceControllerStatus.Running);
return true;
}
else
{
return false;
}
}
catch (Exception)
{
throw;
}
}
這不太可能是因爲你在C#中這樣做。你有沒有嘗試在命令行上使用'sc'?您使用遠程機器上的管理員權限登錄的用戶帳戶?遠程機器的防火牆是否配置爲允許訪問? –