如何在Windows检查是否使用批处理文件没有安装服务 [英] How to check in Windows if the service is not installed using batch file

查看:154
本文介绍了如何在Windows检查是否使用批处理文件没有安装服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图做到这一点需要检查服务是否正在运行检查之前安装的批处理程序/停止。

I'm trying to do a batch program that needs to check if the service is installed before checking if it is running/stopped.

我只是想询问是否有什么办法,我可以检查卸载服务的ERRORLEVEL时,操作系统是Windows XP。

I would just like to ask if there is any way that I can check the ERRORLEVEL of an uninstalled service when the OS is Windows XP.

在我的code片断:

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 here....

我试图用

if errorlevel 1060 goto ServiceError

看来,如果没有安装该服务,上述条件将永远是假的。

It seems that if the service is not installed, the condition above will always be false.

我做出了错误级别____,因为我不知道正确的条件应该的。

I made the errorlevel ____ because I don't know that the correct condition should be.

推荐答案

SC查询为myService |查找为myService> NUL 会做的伎俩

这篇关于如何在Windows检查是否使用批处理文件没有安装服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆