Solved

Batch file with Wait command between commands

Posted on 2008-10-31
3
2,152 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…

730 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