Tuesday 28 May 2013

Batch File to Reboot Multiple Computers

Part 1 - the command line:


This is a pretty simple but can be quite handy. This is the basic command line:

shutdown -r -m \\Computer_Name -t 30 -c "This computer is shutting down in 30 seconds. Best log off now"

The above command, if entered into the cmd line utility, will:
shutdown (shutdown),
then restart (-r),
a specific machine (-m \\ComputerName), 
with a 30 second delay after the command is sent before shutdown command is initialised (-t 30),
And it will also display a comment to whoever happens to be logged on (-c "I am now sentient and have decided to switch myself off in 30 seconds"). 


 
Part 2 - creating the batch file:

Open notepad and then paste the above command line in as many times as needed, tweaking the computer name each time

shutdown -r -m \\ComputerNameA -t 30 -c "This computer is shutting down in 30 seconds. Best log off now"
shutdown -r -m \\ComputerNameB -t 30 -c "This computer is shutting down in 30 seconds. Best log off now"
shutdown -r -m \\ComputerNameC -t 30 -c "This computer is shutting down in 30 seconds. Best log off now"
shutdown -r -m \\ComputerNameD -t 30 -c "This computer is shutting down in 30 seconds. Best log off now"

Then if you Save As..., change the File Type to All Files and name it something useful like Multiple-reboot.bat, you'll have a shiny new batch file which can be run whenever you need or included as part of a scheduled task.

No comments:

Post a Comment