I am writing a batch script to be run in Win 10 OS. However I am facing issues with checking errorlevel of exist status of a Windows command. Faintly I decided to use below way:
findstr /I /C:"EXIT_FAILURE" /I /C:"UNKNOWN" file
if '%ERRORLEVEL%'=='0' goto CHECKFAILED
findstr /I /C:"EXIT_SUCCESS" file
if '%ERRORLEVEL%'!='0' goto CHECKFAILED
exit /B 0
:CHECKFAILED
exit /B 2
Is it the right way to check - I mean compare errorlevel as string or using within single quotes?
The errorlevel when validated for its numeric values leads to understanding considerations that command provides like:
if ERRORLEVEL 0
would mean TRUE for ERRORLEVEL >=0. Similarly there are other considerations.
Hence is it right to use ?& compare ERRORLEVEL as string as mentioned above?