The IF ERRORLEVEL command can be used to check for non-zero return codes in Windows NT 4 and later.
Executables may return negative numbers for errorlevels, but this can be fixed by using the IF %ERRORLEVEL% NEQ 0 command.
It is important to return zero when execution succeeds and non-zero when execution fails.
Additionally, it is recommended to use return codes that are a power of two to record numerous problems in one error code.
See more results on Neeva
Summaries from the best pages on the web
The errorlevel is made available via IF ERRORLEVEL ... or the %ERRORLEVEL% variable.
IF ERRORLEVEL n statements should be read as IF Errorlevel >= number i.e. IF ERRORLEVEL 0 will return TRUE whether the errorlevel is 0, 1 or 5 or 64 IF
Errorlevel - Windows CMD - SS64.com
In CMD.EXE (Windows NT 4 and later) the old-fashioned DOS IF ERRORLEVEL ... may sometimes fail, since executables may return negative numbers for errorlevels! However, this can be fixed by using the following code to check for non-zero return codes: IF %ERRORLEVEL% NEQ 0 ...
Batch files - Errorlevels - Rob van der Woude
This article covers the importance of return codes in Windows programmers, including conventions for returning zero when execution succeeds and non-zero when execution fails, checking for a non-zero return code using the NEQ (Not-Equal-To) operator of the IF command, and conditional execution using the return code. It also provides tips and tricks for using return codes, such as sticking to zero for success and using return codes that are positive values for DOS batch files. Finally, it suggests using return codes that are a power of two to record numerous problems in one error code.
Windows Batch Scripting: Return Codes - /* steve jansen
If you want to retrieve some value produced within the batch (such as a command's error code), your best bet is to send it to some output channel and have…
Get %errorlevel% from batch file