Exit Delayed

Delayed exit without user interaction.

Description: As you develop DOS batch files you may find it annoying to have to hit a key when the application finished just to close the window. You may want to have it close automatically but still being able to briefly scan over the execution result shown in the window.
A way to create a delay in a DOS batch program is to ping the localhost or Sending 2 pings (ping –n 2 ...) will cause a delay of very close to one second. Invoking multiple pings as needed gives control about the delay time. Showing the remaining delay time in the window TITLE will even let the user know what`s going on.
I.e. replace the pause statement added earlier with the following code lines and run the application again. The menu will show a countdown of 5 seconds before closing the application. Changing the number 5 to 10 would result in a 10 second countdown.

What it`s good for:
  • Closing an application without user interaction
  • Leave enough time to view execution results
  • User can hit Pause on the keyboard to keep the window open
::: -- End of application --
FOR /l %%a in (5,-1,1) do (TITLE %title% -- closing in %%as&ping -n 2 -w 1>NUL)
TITLE Press any key to close the application&ECHO.&GOTO:EOF