How to test whether a service is running from the command line

后端 未结 14 1602
天涯浪人
天涯浪人 2020-12-12 18:59

I would like to be able to query whether or not a service is running from a windows batch file. I know I can use:

sc query \"ServiceName\"

相关标签:
14条回答
  • 2020-12-12 19:50

    Try

    sc query state= all 
    

    for a list of services and whether they are running or not.

    0 讨论(0)
  • 2020-12-12 19:50

    I've found this:

      sc query "ServiceName" | findstr RUNNING  
    

    seems to do roughly the right thing. But, I'm worried that's not generalized enough to work on non-english operating systems.

    0 讨论(0)
提交回复
热议问题