HOME
Stephen Knight
10/20/2009 08:51 AM
Simple pause / delay for batch file

Type:

Batch/Command file

Category:

Delay, Pause, Wait, Sleep
There are many ways of causing a pause in a batch file but the easiest assuming that at least one network interface is connected is to use a ping to the localhost because by default a PING is done every 1 second. The first one is nearly immediate so n+1 pings are needed to make n seconds delay.

You can also use the built in function "TIMEOUT" - e.g.

TIMEOUT /T 5

That shows a countdown of how long is left and allows you to press a key to continue. Adding /NOBREAK means pressing a key does not continue - can be stopped using Control C or closing the window as normal.

Show details for CodeCode
Show details for ExplanationExplanation
Hide details for ExamplesExamples


Hide details for AttachmentsAttachments
waittest.cmd