ERRORLEVEL is a number value which is set by programs and may be tested
within a DOS Batch file.
The following batch statements are examples of testing ERRORLEVEL:
CONFIRM Do you really want to exit? (Esc to cancel)
IF ERRORLEVEL 1 GOTO RESUME
GOTO END
The CONFIRM program above displays a message on the screen and
waits for a keystroke. If the keystroke is the Esc key, ERRORLEVEL is
set to 1, any other key sets ERRORLEVEL to 0. The IF ERRORLEVEL
statement above branches to the RESUME label if the user presses Esc,
otherwise the GOTO END statement is executed branching to the END
label.
The IF ERRORLEVEL statement does not check for equality, but is really a
"greater than or equal to" comparison. For example, IF ERRORLEVEL 5
really means: "if ERRORLEVEL is 5 or higher".
If you need to check for a number of ERRORLEVEL possibilities, use a number
of IF ERRORLEVEL statements testing from high to low, like this:
IF ERRORLEVEL 10 GOTO LABEL10
IF ERRORLEVEL 9 GOTO LABEL9
IF ERRORLEVEL 8 GOTO LABEL8
IF ERRORLEVEL 7 GOTO LABEL7
IF ERRORLEVEL 6 GOTO LABEL6
IF ERRORLEVEL 5 GOTO LABEL5
IF ERRORLEVEL 4 GOTO LABEL4
IF ERRORLEVEL 3 GOTO LABEL3
IF ERRORLEVEL 2 GOTO LABEL2
IF ERRORLEVEL 1 GOTO LABEL1
GOTO LABEL0