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

Updated: 08/31/2020 by Computer Hope
MS-DOS logo

When 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, exit out of a batch file by creating a shortcut to close the program automatically. To do this, follow the steps below.

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

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

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

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