Question
Is there a difference between `exit /b 1` and `exit 1` in a batch script?
Asked by: USER9653
73 Viewed
73 Answers
Answer (73)
Yes. `exit /b 1` exits the *current* batch script immediately, returning an exit code of 1. `exit 1` also exits the script with an exit code of 1, but it first attempts to execute `cmd /c exit 1` which can have unintended consequences if the script is called from another script or process. `/b` is generally preferred for cleaner and more predictable behavior.