我目前正在开发桌面应用程序,可启动/停止/重启Windows服务。
public static void StartService(string serviceName, int timeoutMilliseconds)
{
ServiceController service = new ServiceController(serviceName);
try
{
TimeSpan timeout = TimeSpan.FromMilliseconds(timeoutMilliseconds);
service.Start();
service.WaitForStatus(ServiceControllerStatus.Running, timeout);
}
catch
{
// ...
}
}
现在我想要的是一段代码,在远程系统上执行相同的操作(另一个在同一网络中的系统)。
谢谢。