Of course, if possible, without any VBScript-like scripts.
Asked
Active
Viewed 7,128 times
2 Answers
4
Lastnico,
Hello, I think I have a solution to your problem. Try the following:
Try this at your command prompt:
C:\> cmd /c exit /b 4
C:\> echo %errorlevel%
The result should be 4.
Here is a screen shot of my result:
Result of Code http://img691.imageshack.us/img691/7473/cmdc.jpg
I hope this helps,
Thanks!
1
The exit code is stored in the ERRORLEVEL environment variable:
echo %ERRORLEVEL%
To test it you can create a simple batch file that exits using the exit code passed as parameter:
exit_code.bat
@exit /b %1
Testing:
> exit_code.bat 8 > echo %ERRORLEVEL% 8

Kaniabi
- 530
- 5
- 10
-
1my command line is always returning 9009 error code. Do you know why? – Lastnico Nov 20 '09 at 14:45
-
This doesn't seem to work for me. – Scott Nov 20 '09 at 18:11
-
It's just a typo in his code, it's supposed to be %1 instead of %i, no reason to downvote. – JRL Nov 20 '09 at 18:31
-
1I can't un-downvote until the answer is edited. Kaniabi, if you edit your answer to correct, I should be able to un-downvote. Thanks! – Scott Nov 20 '09 at 18:42
-
Ops. Typo fixed. Thanks all for the feedback. – Kaniabi Nov 25 '09 at 11:37
-
Lastnico: Strange return code. I tried to execute with the typo and it always returns 0, not 9009. – Kaniabi Nov 25 '09 at 11:39