Shutdown machine via scheduled task

Reading Time: < 1 minute

The below script will create a schedule task to shutdown the machine at 17:00 daily with a message of “This computer will shutdown in sixty (60) seconds. Please save your work now.”

Copy the below script into a notepad file and rename to something suitable such as shutdown.bat

If you wish to push out the script add the .bat file to computer startup within your group policy. (You may need to reneter speech marks (“) within the script.

SETLOCAL ENABLEDELAYEDEXPANSION

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

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
)

Please follow and like us: