Possible Duplicate:
How to sleep in a batch file?

I have a batch file that runs as a secheduled task in windows server 2003.

This batch file purely calls around 20 other batchfiles one after the other.

When this runs it causes quite a spike on the server and a reduction in performance.

I'd like the ability to add a WAIT or SLEEP type command between each of my batch file calls in order to spread the load out a bit.

Can anyone shed any light on the simplest way of doing this?

marked as duplicate by Massimo, MDMarra, Mark Henderson Sep 26 '12 at 20:25

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


The code you are looking for, looks like this:

ping -n 11 > NUL

The value after "-n" indicates the seconds to wait.
If you want to wait 10secs just add one more ping,
like shown in the example.

Best regards.

P.S.: If you use the powershell, there may be other ways to do this.

  • In PowerShell there is Start-Sleep for that, right :-) – Joey Oct 2 '09 at 16:41
  • 12
    Using ping to pause batch execution is definitely more appropriate for thedailywtf.com than ServerFault... – Massimo Sep 26 '12 at 19:38

The correct way to sleep in a batch file is to use the timeout command, introduced in Windows 2000 Server and Windows XP.

To wait 30 seconds:

timeout /t 30

The timeout would get interrupted if the user hits any key; however, the command also accepts the optional switch /nobreak, which effectively ignores anything the user may press, except an explicit CTRL-C:

timeout /t 30 /nobreak

Additionally, if you don't want the command to print its countdown on the screen, you can redirect its output to NUL:

timeout /t 30 /nobreak > NUL

There's a W2K3 resource kit utility called sleep.exe that you can use by calling it in the batch file and telling it how long to "sleep" before moving on to the next command.


net use X: \server\share /Delete

sleep 300

net use X: \server\share


The best way is to use 'ping', but you can find more ways here: http://drbatcher.blogspot.com/2009/10/pauses-and-delays-in-batch-scripts.html

  • 4
    That's by no means "the best way". – Massimo Sep 26 '12 at 19:37

Not the answer you're looking for? Browse other questions tagged or ask your own question.