How to check if a service is running via batch file and start it, if it is not running?

后端 未结 14 1613
暖寄归人
暖寄归人 2020-11-30 18:15

I want to write a batch file that performs the following operations:

  • Check if a service is running
    • If is it running, quit the batch
    • If
14条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-30 18:45

    @echo off
    
    color 1F
    
    
    @sc query >%COMPUTERNAME%_START.TXT
    
    
    find /I "AcPrfMgrSvc" %COMPUTERNAME%_START.TXT >nul
    
    IF ERRORLEVEL 0 EXIT
    
    IF ERRORLEVEL 1 NET START "AcPrfMgrSvc"
    

提交回复
热议问题