MS-DOS and Windows command line exit command

Updated: 11/30/2020 by Computer Hope
exit command

The exit command is used to withdraw from the currently running application and the MS-DOS session.

Availability

Exit is an internal command and is available in the following Microsoft operating systems.

Exit syntax

Windows Vista and later syntax

Quits the CMD.EXE program (command interpreter) or the current batch script.

EXIT [/B] [exitCode]
/B Specifies to exit the current batch script instead of CMD.EXE. If executed from outside a batch script, it quits CMD.EXE.
exitCode Specifies a numeric number. If /B is specified, sets ERRORLEVEL that number. If quitting CMD.EXE, sets the process exit code with that number.

Windows XP and earlier syntax

Quits the COMMAND.COM program (command interpreter).

EXIT

Exit examples

exit
  • When in another command interpreter, exit takes you out of the new command interpreter and back into the original.
  • When entering DOS from Windows, exit would return you to Windows.
  • If you're in the Recovery Console, exit would close the Recovery Console and reboot the computer.

Additional information