This is the latest version of what I am using in practice for a ten second pause to see the output when a script finishes.
BEST>@echo done
BEST>@set DelayInSeconds=10
BEST>@rem Use ping to wait
BEST>@ping 192.0.2.0 -n 1 -w %DelayInSeconds%000 > nul
The echo done allows me to see when the script finished and the ping provides the delay. The extra @ signs mean that I see the "done" text and the waiting occurs without me being distracted by their commands.
I have tried the various solutions given here on an XP machine, since the idea was to have a batch file that would run on a variety of machines, and so I picked the XP machine as the environment likely to be the least capable.
GOOD> ping 192.0.2.0 -n 1 -w 3000 > nul
This seemed to give a three second delay as expected. One ping attempt lasting a specified 3 seconds.
BAD> ping -n 5 192.0.2.0 > nul
This took around 10 seconds (not 5). My explanation is that there are 5 ping attempts, each about a second apart, making 4 seconds. And each ping attempt probably lasted around a second making an estimated 9 seconds in total.
BAD> timeout 5
BAD> sleep /w2000
BAD> waitfor /T 180
BAD> choice
Commands not available.
BAD> ping 192.0.2.0 -n 1 -w 10000 > nul :: wait 10000 milliseconds, ie 10 secs
I tried the above too, after reading that comments could be added to BAT files by using two consecutive colons. However the software returned almost instantly. Putting the comment on its own line before the ping worked fine.
GOOD> :: wait 10000 milliseconds, ie 10 secs
GOOD> ping 192.0.2.0 -n 1 -w 10000 > nul
To understand better what ping does in practice, I ran
ping 192.0.2.0 -n 5 -w 5000
This took around 30 seconds, even though 5*5=25. My explanation is that there are 5 ping attempts each lasting 5 seconds, but there is about a 1 second time delay between ping attempts: there is after all little reason to expect a different result if you ping again immediately and it is better to give a network a little time to recover from whatever problem it has had.
Edit: stolen from another post, .. RFC 3330 says the IP address 192.0.2.0 should not appear on the internet, so pinging this address prevents these tests spamming anyone!
I have modified the text above accordingly!