How to sleep in a batch file?

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:

timeout /t 30

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 explicit CTRL-C:

timeout /t 30 /nobreak

Additionally, if you don’t want the command to print its countdown on the screen, you can redirect its output to NUL:

timeout /t 30 /nobreak > NUL

Leave a Comment