You are here: > >

How to exit a Windows MS-DOS window through a batch file

MS-DOSWhen a batch file is complete, Microsoft Windows will leave the window open, requiring the user of the computer to manually close it. For convenience, the individual writing the batch file may want to automatically close that window.

Add the "exit" command to the end of your batch file. See the exit command page for additional information about this command.

Alternatively, if you are using Windows 95, 98, ME, or NT you can exit out of a batch file by creating a shortcut to close the program automatically. To do this, follow the steps below.

  1. Create a shortcut to the MS-DOS program or batch file.
  2. Right-click the new shortcut and click Properties.
  3. Click on the Programs tab.
  4. Check the box to Close on exit.
  5. Click Apply and then Ok.

Note: This option is no longer available in versions of Windows after 2000.

Finally, it is important to realize that if a batch file or program is still running a program the MS-DOS windows will not close until it has completed. Therefore an MS-DOS window may remain open either because the program stopped responding or because it's still performing tasks.

Additional information