How to ReBoot all the machines at a time.


Pre-requisite:

a. Windows 2003 machine
b. Login or the scheduled job that runs this reboot.bat should have admin access to all the machines

Steps:

1. Step1: Create D:\scripts\reboot\serverlist.txt and the list all the machines that you want to reboot.

Example:
MyServer
SQL1Prod
SQL1QA
DOTNET1a

2. Step2: Create D:\scripts\reboot\reboot.bat 

REM Objective: TO reboot all the 
  machines listed in D:\script\reboot\serverlist.txt
REM Created by : MAK
REM Created Date: Jan 5, 2005
REM Save this file as 
  D:\scripts\reboot\reboot.bat
for /f "tokens=1,2,3" %%i in 
 (D:\scripts\reboot\serverlist.txt) 
 do c:\windows\system32\shutdown.exe /m \\%%i /r /f /c 
 "You machine is going to be restarted in 10 minutes" /t 600

3. Step3: Create D:\scripts\reboot\Abortreboot.bat

REM Objective: TO abort reboot on all the machine listed in 
  D:\script\reboot\serverlist.txt
REM Created by : MAK
REM Created Date: Jan 5, 2005
REM Save this file as D:\scripts\reboot\abortreboot.bat
for /f "tokens=1,2,3" %%i in 
  (D:\scripts\reboot\serverlist.txt) 
  do c:\windows\system32\shutdown.exe /a /m \\%%i 
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Code for Reboot.bat
----------------------
REM Objective: TO reboot all the machine listed in D:\script\reboot\serverlist.txt
REM Created by : MAK
REM Created Date: Jan 5, 2005
REM Save this file as D:\scripts\reboot\reboot.bat
for /f "tokens=1,2,3" %%i in (D:\scripts\reboot\serverlist.txt) do c:\windows\system32\shutdown.exe /m \\%%i /r /f /c "You machine is going to be restarted in 10 minutes" /t 600

Code for AbortReboot.bat
-------------------------
REM Objective: TO abort reboot on all the machine listed in D:\script\reboot\serverlist.txt
REM Created by : MAK
REM Created Date: Jan 5, 2005
REM Save this file as D:\scripts\reboot\abortreboot.bat
for /f "tokens=1,2,3" %%i in (D:\scripts\reboot\serverlist.txt) do c:\windows\system32\shutdown.exe /a /m \\%%i
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: