用bat命令创建Windows服务,存在则启动

判断服务是否存在,存在就直接启动,不存在则创建后启动,引号里的内容替换成自己的服务名即可

 

@echo off
sc query SAVUS_SFCJSService |findstr /i "STATE">nul
if not errorlevel 1 (goto exist) else goto notexist

:exist
sc start "SService"
pause
goto end

:notexist
sc create "SService" binpath= "%~dp0\SAVUS_SFCJS.exe /S" type= own start= demand obj= localsystem Displayname= "SService"
sc start "SService"
pause
goto end

  

上一篇:Chrome报错:Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist.


下一篇:Latex中数学公式中常用符号(持续更新)