How Can I Schedule a Reboot?

  • Thread starter Thread starter Brandon S.
  • Start date Start date
B

Brandon S.

I would like to schedule my server to reboot once a week (to help prevent
some problems that are solved by a reboot). How would I go about doing this
(if it's possible)? I looked in Scheduled Tasks, but I don't know what to
choose to make it reboot.
 
Add this code to a .vbs file (call it "shutdown.vbs"):

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(Shutdown)}!\\" &
strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery _
("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
ObjOperatingSystem.Reboot()
Next

Call this file from the Task Scheduler on a weekly basis -
this will reboot the computer - it appears to force close
any open programs as well.
 
Back
Top