Windows Command Line

Schedule a PC to Shutdown Batch File

Problem

If you are trying to save some money in your organisation you are trying to be a little more green then you can do this by making sure that no computers are left on after a certain time. Additionally you may end up making these computers last that little bit longer as they will not be running 24/7. Now there are two ways of doing this walk around your sire and manually turn them off or do it automatically. Follow this step by step guide below on how to schedule a computer to shutdown automatically at a set time.

Solution

Copy the txt below into notepad and save the file as “shutdown.bat” or anythingyoulike.bat. Then deploy it to your pcs`s either manualy or via a login script.

You can change the time in the cript by locating the “18:00 ” section and pop the time in you require

SETLOCAL ENABLEDELAYEDEXPANSION

SET strShutdownPath=%SystemRoot%\System32\
SET strShutdownProgram=shutdown.exe
SET strShutdownComment=This computer will shutdown in sixty (60) seconds. Please save your work.

IF EXIST “%SystemRoot%\System32\schtasks.exe” (
ECHO Task Scheduler Found, Executing Command…
ECHO:
SCHTASKS /Create /RU “SYSTEM” /SC “DAILY” /TN “Computer Shutdown” /TR “%strShutdownPath%%strShutdownProgram% -s -t 60 -c \”!strShutdownComment!\” -f” /ST “18:00:00″ /SD “20/09/2010″
EXIT
) ELSE (
ECHO Task Scheduler NOT Found, Ending Script…
EXIT
)

Tags: Shutdown script

Allen White

Allen is a Consultant for ITPS in the North East of England and holds the following accreditations. MCSA, MCSE, MCTS, MCITP, CCA, CCSP, VCP 4,5 and HP ASE, AIS - Network Infrastructure.

Leave a comment

Categories

Vote!

What Web Browser Do You Use?

View Results

Loading ... Loading ...

Vote!

What do you prefer..VMware or Hyper-V?

View Results

Loading ... Loading ...