Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I return a value in a Windows batch file? I can do it in Unix using exit 1 but how can I do it in Windows?

share|improve this question
Do you mean Windows BATCH file? Or do you actually have GNU Bash installed on Windows? – Zoredache Oct 3 '10 at 8:34
Windows BATCH file – Mohammad AL-Rawabdeh Oct 3 '10 at 8:46
up vote 4 down vote accepted

In a windows batch file to return a value back to the command shell use

exit /b yourexitcode


exit /b 3

will retun 3 in %ERRORLEVEL%

share|improve this answer

In Windows:

exit /b 1
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.