Solved

Batch file with Wait command between commands

Posted on 2008-10-31
3
2,132 Views
Last Modified: 2012-06-21
I want to remotely restart a bunch of computers, but I do not want them all to reboot at the same time. I have a batch file below that i want to insert a WAIT command, so that the batch file will execute a command on one line, wait maybe 5 minutes, then go to the next line execute the command, wait 3 minutes, execute the command, etc.

what is the command i will put after each line to tell the batch to wait before moving to the next line?
shutdown -m \\servername1 -r -f

shutdown -m \\servername2 -r -f

shutdown -m \\servername3 -r -f

shutdown -m \\servername4 -r -f

shutdown -m \\servername5 -r -f

shutdown -m \\servername6 -r -f

shutdown -m \\servername7 -r -f

Open in new window

0
Comment
Question by:thesurg3on
  • 2
3 Comments
 

Expert Comment

by:Jholguin
ID: 22852633
I had a situation where I needed to add a delay to a batch file as well and I used ping for X number of seconds:

ping -n X 127.0.0.1 > NUL

so for 5 minutes just add 300 for X and you're good to go.
0
 
LVL 4

Accepted Solution

by:
keamo earned 500 total points
ID: 22852750
Can you try the "sleep" command...?

C:\>sleep
Usage:  sleep      time-to-sleep-in-seconds
        sleep [-m] time-to-sleep-in-milliseconds
        sleep [-c] commited-memory ratio (1%-100%)
0
 
LVL 4

Expert Comment

by:keamo
ID: 22852762
"Sleep.exe" is part of the W2K3 Resource kit.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now