The simplest way to make a delay or pause for a certain amount of time, is with the standard command TIMEOUT
. To make a timeout that lasts exactly one minute we type:
timeout /t 60
Now what is going on here?
First off we use the command TIMEOUT
with the parameter /T
(which simply means timeout) then we specify the amount of seconds to wait. In this case... 60
seconds.
Timeout with the parameter /NOBREAK
If we take the example from before and run that in a BATCH file: timeout /t 60
then while waiting those 60 seconds, you are actually able to break the timeout by pressing any key on your keyboard. To prevent this we simply add the parameter /NOBREAK
to the end of it.
timeout /t 60 /nobreak
By doing this it will timeout for 60 seconds, and if you want to break the timeout you will have to press (CTRL-C) on your keyboard.
Silent timeout
When it's doing a timeout it will display:
Waiting for X seconds, press a key to continue ...
or
Waiting for X seconds, press CTRL+C to quit ... [This is with the /NOBREAK parameter]
To hide the message use the NUL
argument (For explanation of NUL
: Click Here)
timeout /t 60 > nul
or
timeout /t 60 /nobreak > nul