判断服务是否存在,存在就直接启动,不存在则创建后启动,引号里的内容替换成自己的服务名即可
@echo off sc query SService |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= "%~dp0SSFCJS.exe /S" type= own start= demand obj= localsystem Displayname= "SService" sc start "SService" pause goto end