2013-04-09 159 views
2

通常,當需要知道的現有服務器的服務狀態的一個手段很容易被從發現從ServiceController的結果通過粘貼下面的代碼:如何找出在一臺服務器上運行在另一臺服務器上的Windows服務狀態?

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(); 
} 

在這裏,我想知道另一臺機器的服務狀態,我怎麼能找出結果可以任何一個能夠指導我在這種情況下。

+0

http://www.codeproject.com/Articles/4242/Command-Line-Windows-Services-Manager,http://stackoverflow.com/questions/6866104/c-sharp-service-status-on-remote -機 – Arie 2013-04-09 08:17:50

回答

相關問題