bat判断服务是否存在

REM 将引号内部分改为你要查找的服务名称

sc query |find /i "mysql" >nul 2>nul


REM 若是服务存在,跳转至exist标签

if not errorlevel 1 (goto exist) else goto notexist

REM 服务存在时启用mysql服务

:exist

echo 服务存在

goto :eof

REM 服务不存在时安装mysql服务

:notexist

echo 服务不存

goto :eof
相关文章
相关标签/搜索