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

前端 未结 2 492
终归单人心
终归单人心 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
    }
    

提交回复
热议问题