How to check in Windows if the service is not installed using batch file

前端 未结 2 491
终归单人心
终归单人心 2021-01-21 12:49

I\'m trying to do a batch program that needs to check if the service is installed before checking if it is running/stopped.

I would just like to ask if there is any way

相关标签:
2条回答
  • 2021-01-21 13:16

    According to this answer this is possible in batch using method you described How does one find out if a Windows service is installed using (preferably) only batch?

    Alternatively you could query with powershell:

    $serv_status = get-service "myService"
    if($serv_status -ne $null) 
    { 
        // do some operations here
    }
    
    0 讨论(0)
  • 2021-01-21 13:17

    sc query myService |find "myService" >nul will do the trick

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