如何从一台服务器上查找正在另一台服务器上运行的windows服务状态
本文关键字:一台 服务器 运行 服务 状态 windows 查找 | 更新日期: 2023-09-27 18:08:16
通常,当需要知道现有服务器中的一个服务状态时,意味着很容易通过粘贴下面的代码从servicecontroller中找到结果:
ServiceController sc = new ServiceController("servicename");
if ((sc.Status.Equals(ServiceControllerStatus.Stopped)) ||
(sc.Status.Equals(ServiceControllerStatus.StopPending)))
{
// Start the service if the current status is stopped.
sc.Start();
}
这里我想知道另一台机器的服务状态,我怎样才能知道结果,有没有人可以指导我这个场景
ServiceController的另一个构造函数将机器名作为第二个参数。http://msdn.microsoft.com/en-us/library/ssbk2tf3.aspx
你试过吗?