Commands usually set error level at the end of their execution. In Windows NT and later, it is a 32-bit signed integer; in MS DOS, it used to be an integer from 0 to 255. Keywords: return code, exit code, exit status.
The conventional meaning of the error level:
Uses of the error level:
&&
and ||
; see also syntax.ERRORLEVEL
variable.Examples:
dir >NUL && echo Success
color 00 || echo Failure
color 00 || ( echo Failure)
echo %ERRORLEVEL%
if %errorlevel% equ 0 echo The error level is zero, meaning success.
if %errorlevel% neq 0 echo The error level is non-zero, meaning failure.
if errorlevel 1 echo The error level is >= 1, meaning failure via positive error level.
>=
part: this is not the same as if %errorlevel% equ 1
.exit /b 1
cmd /c "exit /b 10"