I have some bat scripts where I have to wait for X seconds, currently I am just calling sleep which works fine. However, I would like to count to the number that is passed in so I can at least see how long I have left to wait.
But I cannot seem to find how to count to X and output that to the console. Simple I know…
If possible, I would like the numbers to overwrite each other as it counts so that it doesnt fill the screen with numbers.
Can anyone help me here?
SLEEP is not a standard Windows command.
If you have a recent version of Windows (ie Vista or better, thanks Neil), you can use the TIMEOUT command (use
TIMEOUT /?to get help on usage)The TIMEOUT command does exactly what you are asking for. It counts down the seconds until it reaches 0. The user has the ability to press a key to abort the wait and proceed immediately. The /NOBREAK option disables the ability to skip the wait.
For example, this command will wait for 5 seconds, with a visual countdown.