?
Solved

Batch file with Wait command between commands

Posted on 2008-10-31
3
Medium Priority
?
2,176 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 2000 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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

If like me you are one who spends a lot of time working and scripting with cmd.exe, sometimes it is handy to be able to quickly view a calendar for a given month and year. This script will quickly do just that!  Save the code posted below to a .bat …
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month12 days, 13 hours left to enroll

777 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