小编Wes*_*son的帖子

如果使用批处理文件未安装服务,如何检入Windows

我正在尝试做一个批处理程序,需要检查服务是否已安装,然后再检查它是否正在运行/停止.

我想问一下,当操作系统是Windows XP时,是否有任何方法可以检查已卸载服务的ERRORLEVEL.

在我的代码段中:

ver | find /I "XP"
if %errorlevel%==0 goto ver_xp
goto ver_nonXP

:ver_xp
echo Windows XP
sc query myService > nul
echo %errorlevel%
if errorlevel ___I goto ServiceOk
if errorlevel ___ goto ServiceError
goto ServiceError

:ver_nonXP
echo Windows is not XP
sc query myService > nul
echo error1_percent %errorlevel%
if %errorlevel%==0 goto ServiceOk
if %errorlevel% NEQ '0' goto ServiceError
goto end

:ServiceError
echo Service is not installed
net helpmsg %errorlevel%
goto end

:ServiceError
rem do some operations …
Run Code Online (Sandbox Code Playgroud)

service batch-file

2
推荐指数
1
解决办法
2164
查看次数

标签 统计

batch-file ×1

service ×1