Need to configure workstations to reboot each night...

techtips

Gawd
Joined
Jan 3, 2011
Messages
530
hey everybody, I am wondering how I can configure 80+ workstations so that they can all reboot before our site backup occurs?

I've tried to test this using task scheduler, created a reboot.bat file with the following code:

shutdown.exe /r /f / t00
pause

i've tried to run that program and it wont run from task scheduler. Our server is running Server2003 if that helps anyway. Would there be an easier way to implement this code on all the units rather then going from computer to computer once I get the batch/script to work?

thank you
 
Last edited:
VB Script and a text file.. Let me find the code we were using to reboot the computers.
 
Put this in the run line of your scheduled task:

C:\WINDOWS\system32\shutdown.exe -r -t 00

I run this on all of my terminal servers to kill off user logins every night. Works a charm.
 
Drop this on a server with admin rights to all of the machine and then populate the text file with the computers you want rebooted. Create a scheduled task to and point it to this vb script, select a time. Sit back and enjoy

Code:
On Error Resume Next

const ForReading = 1

Const SHUTDOWN = 12
Const REBOOT = 6
Const LOGOFF = 4

'Finished = "This script has completed."

Set fso = CreateObject("Scripting.FileSystemObject")

'***********************************************************
'Open one text file as a text stream for reading and one text
'file as a stream for writing. Don't create a file if 
'Servers.txt and ServicesAdjusted.txt don't exist.
'***********************************************************

Set tsInputFile = fso.OpenTextFile("C:\Reboot.txt", ForReading, False)

While Not tsInputFile.AtEndOfStream
	'**************************************************************
	'Read a line
	'**************************************************************
	strLine = tsInputFile.ReadLine
	strComputer = strLine

	Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate,(shutdown)}!\\" & strComputer & "\root\cimv2")
	Set colOperatingSystems = objWMIService.ExecQuery _
    	("SELECT * FROM Win32_OperatingSystem")
	For Each objOperatingSystem in colOperatingSystems
    	ObjOperatingSystem.Win32Shutdown(REBOOT)
	WScript.Sleep 5000
	Next

Wend


tsInputFile.Close

'wscript.echo Finished
 
Nice script, but not necessary unless you have lots of servers you want to reboot. Maybe good for his workstation deal.
 
It was originally a shut down script from a guy who use to work at a college. To go "green" they would shut down all of the computer lab's every night. I think at the end of the night it probably shut down 50ish some computers

I used to to restart Citrix / TS in the middle of the night, and throughout the week so they had a fresh clean start.

I was also used to screw with people sometimes, but I wouldn't know much about that ;)
 
Back
Top