How to pause execution for a while in a Windows batch file between a command and the next one?
The correct way to sleep in a batch file is to use the
To wait somewhere between 29 and 30 seconds:
The timeout would get interrupted if the user hits any key; however, the command also accepts the optional switch
Additionally, if you don't want the command to print its countdown on the screen, you can redirect its output to
Since it applies here, too, I'll copy my answer from another site.
If you want to use ping, there is a better way. You'll want to ping an address that does not exist, so you can specify a timeout with millisecond precision. Luckily, such an address is defined in a standard (RFC 3330), and it is
To sleep for 123 milliseconds, use
You can also insert a ping to localhost. This will take 4 seconds to complete (by default). It is considered a kludge by some, but works quite well all the same.
protected by Michael Hampton♦ Dec 2 '15 at 22:31
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?