Question Locked

How do I run a batch file to remote restart multiple machines?

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have been trying to run a .bat that will restart multiple machines over the domain.

shutdown -r -c "comment" -t 45 -m \\machinename

above works fine with one machine but i am all about saving time if this could be run on many machines at once.

2 replies

by Former member

Hope this works for you.

Generate a list of your servers in a text file(for this example we will call the file srvrs.txt). The text file can have them in the format like \\servername, or just servername.
-- create a batch file (for this example, we will call it
shtdwn.cmd) The batch file should have something like this in it,

for /f "tokens=1-3" %%c in (srvrs.txt)
do call shutdown \\%%c /T:5 /y /C

The two lines above should only be one line.

if the file that contains your server list has the \\ in front of the server name, then do not place them after the word shutdown in the line above. so it would read shutdown %%c

/T: changes the default time delay of 20, to 5, or what ever you want to set it to.

/y automatically answers yes to all/any questions prompted for.

/C forces all applications that may be open to close

You can also use /R to force a restart after shutdown.

Please post back if you have any more problems or questions.
If this information is useful, please mark as helpful. Thanks.

This discussion is closed to new replies.