Windows command to get service status?

后端 未结 12 769
渐次进展
渐次进展 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

    If PowerShell is available to you...

    Get-Service -DisplayName *Network* | ForEach-Object{Write-Host $_.Status : $_.Name}
    

    Will give you...

    Stopped : napagent
    Stopped : NetDDE
    Stopped : NetDDEdsdm
    Running : Netman
    Running : Nla
    Stopped : WMPNetworkSvc
    Stopped : xmlprov
    

    You can replace the ****Network**** with a specific service name if you just need to check one service.

提交回复
热议问题