Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I few days ago, a guy named Nathan tried to get a timed delay on a batch file. He stated that he had tried using the PING command, like this (in this case to wait 60 seconds):
ping 1.1.1.1 -n 60 -w 1000
Which specifies 60 pings with a timeout of 1000 miliseconds, firing against a non-existant (though valid) IP, so the whole timeout takes place. However, that won't work as intended, the delay time is way longer than 60 seconds and is pretty unpredictable.
I observed that such unexpected behavior seems to be caused by delays between different pings. So, I had an idea - use a single ping with the timeout being the whole wait time. We would do this, instead, to wait 60 seconds:
ping 1.1.1.1 -n 1 -w 60000
And guess what... It works just fine! So, let me analyse that new method:
Goods:
1. It doesn't require any 3rd party applications.
2. It will work under most versions of Windows.
3. It works properly as intended, taking a delay on the right amouth of time.Bads:
1. It's a method restricted to batch files running under Windows. The application PING.exe won't work out of Windows.
2. When under Win98, CTRL+C and CTRL+BREAK don't seem to work during the delay, that is, the delay is not skipped. They do eventually take effect, but only after the delay has gone.The undesired output from the command can be supressed by redirecting it to NUL:
ping 1.1.1.1 -n 1 -w 60000 > nul
That's it! Comments are welcome.
Thanks for Nathan for bringing this idea up.-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br

By the way, using CHOICE.COM to create a delay is a known method. However, such application is not avaliable on NT systems, which creates the need for another method.
-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br

Indeed, "choice" is the best thing for that .. but if it isnt on the system .. well, you could try and "steal" it from another OS .. I have seen similar stuff work
Otherwise; lend something from DOS his superior friend, called unix : sleep

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |