1

I have a batch program that calls several child batch programs and they make extensive use of various Windows commands. In case of error, I would like to provide logging information about the error details to the user.

How do I know what are the various error codes (a number in the range 0 to 256) that these commands can return and what are their interpretations in English?

1 Answer 1

2

If you really are on DOS (which I highly doubt) then the only way is

command
if errorlevel 255 echo 255
if errorlevel 254 echo 254
if errorlevel 253 echo 253
...
if errorlevel 1 echo 1
if errorlevel 0 echo 0

The interpretations in a natural language are then up to you, as you should know what exactly you did try there.

Note that on Windows you can usually just do

command
echo %errorlevel%
Sign up to request clarification or add additional context in comments.

6 Comments

I am on Windows 7. I am using the command shell (cmd.exe) for executing the batch programs.
@Santhosh: Then please, please stop talking about MS-DOS. It's incorrect and misleading.
I think the OP is asking about a listing of what cmd.exe command's errorlevels indicate, as the above address' correctly
This is for figuring them out, as documentation is often scarce.
it's important to note that programs can set their own ERRORLEVEL. So the number returned by xcopy somefile.ext ... for "file not found" could be different from robocopy somefile.ext .... So you need to do the test above on a command by command basis (in the absence of authoritative docs).
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.