Name

exit

Synopsis

End the current Command Prompt session and close the window.

Syntax

exit [/b] [exitcode]

Description

Typing exit has the same effect as closing the Command Prompt window with the [x] button.

exit accepts the following options:

/b

If exit is used from within a batch file, it will close the current Command Prompt window. Specify /b to exit the batch file but leave cmd.exe running.

exitcode

Specifies a numerical “exit code” number that is passed to the application or process that launched the Command Prompt or started the batch file. Exitcode is typically used when one batch file runs another batch file and wishes to report to the “parent” batch file whether successful or not.

Notes

If you start a new Command Prompt session by typing cmd in an open Command Prompt window, exit will end that session. However, since the “parent” session is still active, the window won’t close until you type exit again.

Get Windows XP in a Nutshell now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.