Windows command to get service status?

后端 未结 12 893
渐次进展
渐次进展 2021-02-01 04:48

I need to know the status of a service at the end of my batch script which restarts services using \"net stop thingie\" and \"net start thingie\".

In my most favorite id

12条回答
  •  灰色年华
    2021-02-01 05:17

    Using Windows Script:

    Set ComputerObj = GetObject("WinNT://MYCOMPUTER")    
    ComputerObj.Filter = Array("Service")    
    For Each Service in ComputerObj    
        WScript.Echo "Service display name = " & Service.DisplayName    
        WScript.Echo "Service account name = " & Service.ServiceAccountName    
        WScript.Echo "Service executable   = " & Service.Path    
        WScript.Echo "Current status       = " & Service.Status    
    Next
    

    You can easily filter the above for the specific service you want.

提交回复
热议问题