How to Get the Exit Code of a Windows Command Line Application

Since I regularly forget the exact name and end up having to look this up, I’m documenting it here.

If you run an application from the command-line and want to get it’s exit status code, you use:
[bat gutter=”false”]
echo %ERRORLEVEL%
[/bat]

Beware however, if there is an environment variable called errorlevel, because it will override the exit code.

See this SO question for more information.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.