Errorlevel
When a program stops, it returns an exit code to MS-DOS. For example, a
value of 0 is typically used to indicate that a program was successfully
executed. The ERRORLEVEL parameter lets you use exit codes as conditions.
The following example displays an error message if an error occurs during
formatting of the disk in drive A. If no error occurs, the error message is
skipped.
:begin
echo off
format a: /s
if not errorlevel 1 goto end
if errorlevel 2 goto other
echo An error occurred during formatting.
: other
echo do other things
:end
echo End of batch program.
http://users.cybercity.dk/~bse26236/batutil/help/CHOICE_E.HTM#el