How to pause execution for a while in a Windows batch file between a command and the next one?
Windows – How to sleep in a batch file
batchbatch-filewindows
batchbatch-filewindows
How to pause execution for a while in a Windows batch file between a command and the next one?
Best Answer
The correct way to sleep in a batch file is to use the
timeout
command, introduced in Windows 2000.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
/nobreak
, which effectively ignores anything the user may press, except an explicitCTRL-C
:Additionally, if you don't want the command to print its countdown on the screen, you can redirect its output to
NUL
: