@echo off
for /f "skip=3 tokens=4" %%i in ('sc query "myservice1"') do set "zf=%%i" &goto :next2
:next2
if /i "%zf%"=="" (echo 该服务已被卸载!
) else (
if /i "%zf%"=="RUNNING" (
net stop "myservice1"
)
sc delete "myservice1"
)
) else (
if /i "%zf%"=="RUNNING" (
net stop "myservice1"
)
sc delete "myservice1"
)
for /f "skip=3 tokens=4" %%i in ('sc query myservice2') do set "zt=%%i" &goto :next
:next
if /i "%zt%"=="" (echo 该服务已被卸载!
) else (
if /i "%zt%"=="RUNNING" (
net stop myservice1
)
sc delete myservice1
)
if /i "%zt%"=="" (echo 该服务已被卸载!
) else (
if /i "%zt%"=="RUNNING" (
net stop myservice1
)
sc delete myservice1
)
本文转自lidup 51CTO博客,原文链接:http://blog.51cto.com/lidup/305334,如需转载请自行联系原作者