Pause Batch Script for a Number of Seconds
Filed under:
Deployment Solution, Deployment Solution for Dell Servers, Software Delivery Solution, Notification Server
Scripting, Best Practices, System
Submitted by CondorMan on 26 June, 2008 - 10:17.
There are a few ways to have a batch script wait for a number of seconds. The simplest and most widely available without any additional programs is to use the ping command.
The following is is an example... PING!
ECHO Waiting 5 seconds PING 1.1.1.1 -n 1 -w 5000 > NUL
(31 votes)
- Login or register to post comments
- 4056 reads
- Printer-friendly version
















SFU
You can also use the sleep command just like on *NIX boxes. You can get it from Microsoft Services for UNIX.
I typically use ping also,
I typically use ping also, even though it's a common batch hack. These days, I prefer relying on PowerShell instead of plain batch files though.
Better to use the loop back address
You should use the loop back address versus a non existing ip
ECHO Waiting 5 seconds
PING 127.0.0.1 -n 1 -w 5000 > NUL
Your method for a timer is nice since it doesn't use any "Special" commands or require additional software to be loaded like powershell.
New Syntax for Windows/PE
I found that the syntax is different in Windows based DOS.
REM Wait 5 seconds
ping -n 5 127.0.0.1 > nul