I'm trying to do a batch program that needs to check if the service is installed before checking if it is running/stopped.
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.
In my code snippet:
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....
I tried to use
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.