Schedule Windows server to reboot or shutdown automatically

Sometime it is necessary to reboot (or shutdown) windows server. Under UNIX or Linux you can use reboot / hal t/shutdown command via cron jobs or at command. But, when it comes to Windows server there is no built in command exist. Only Windows 2000 Resource Kit offers shutdown command line utility.

However, sysinternals has nifty utility called PsShutdown. It is a command-line utility similar to the shutdown utility from the Windows 2000 Resource Kit, but with the ability to do much more. In addition to supporting the same options for shutting down or rebooting the local or a remote computer, PsShutdown can logoff the console user or lock the console (locking requires Windows 2000 or higher). PsShutdown requires no manual installation of client software.

How do I schedule Windows Server Reboot / Shutdown?

You can download PsShutdown from sysinternals web site.

Store file on Windows server in folder. I use folder called C:\admutils. Next open windows command prompt (Start > Run > cmd) and use windows at command to schedule reboot:
c:> at 2:00am c:\admutils\psshutdown.exe -r -f -c -t 10
Above command will reboot system at 2am. If you want to shutdown system:
c:> at 1:00am c:\admutils\psshutdown.exe -s -f -c -t 10
Where,

  • -s: Shutdown windows server
  • -r: Reboot windows server
  • -f: Forces all running application to exit
  • -c: Allow the shutdown to by cancel by user
  • -t: Specifies the countdown in seconds until the shutdown

I dont think there is a solution to reboot through AD…but here is a good way to do it….

If you are doing it during work hours use the shutdown.exe command that is free from Microsoft…simply enter…

shutdown.exe \\PCNAME /R /T:10 “Message” /C

/R – Reboots the machine
/T:10 – give it 10 seconds for anyone to save work if they need to (Can be whatever time)
“Message” – a message to any users on the PC at the time. (Eg you have 30 seconds)
/C – Causes all porgrams open to close down

You can create a scheduled task to do this out of hours by putting this (shutdown.exe \\PCNAME /R /T:10 “Message” /C) in the Run part of the scheduled task

To do this to lots of PC’s at the same time do a simple command script….

Put the shutdown.exe file on the c: drive
Create PClist.txt file on the C: Drive

Create a txt file and rename the .txt part at the end of the file .cmd

right click and select edit and type in there….
—————————————————-

@Echo Off

SET PCNAMES=”C:PCList.txt”

FOR /F %%a IN (%PCNAMES%) DO CaLL :DODEL %%a

GOTO :EOF

:DODEL
SET BRSVR=%1
ECHO %BRSVR%

C:\shutdown.exe \\%PCNAMES% /R /T:10 “Message” /C

—————————————————

In the PCList put in the names of the PC’s for example….

Server01
PC01
Laptop01

Then click the cmd script and this will apply this to all the pc’s and restart each of them