Code: Select all
:: Check if the MyService service exists
where sc >nul 2>nul
if %errorlevel% equ 0 (
sc query MyService | find "STATE" >nul
echo Errorlevel is %errorlevel%
if %errorlevel% neq 0 (
echo MyService service does not exist.
goto RIGHT
)
) else (
echo "The script was unable to locate sc.exe . The installer script uses sc.exe to check if the MyServcie service is installed and in a RUNNING state. To remedy this error, copy sc.exe from a Windows PC that is the same version as this PC and place it in %windir%\System32.
pause
exit /b
)
:WRONG
echo This is the wrong area
exit /b
:RIGHT
echo This is the right area
exit /b
If I manually run this, errorlevel is 1
Code: Select all
sc query MyService | find "STATE" 1>nul