19 lines
1.1 KiB
Batchfile
19 lines
1.1 KiB
Batchfile
@echo off
|
|
|
|
REM #############################################################
|
|
REM # @description: #
|
|
REM # Add task to automatically shut down the system at 6PM #
|
|
REM # #
|
|
REM # @project: IMGSystTools #
|
|
REM # @author: Bram Prieshof #
|
|
REM #############################################################
|
|
|
|
NET SESSION >nul 2>&1
|
|
IF %ERRORLEVEL% EQU 0 (
|
|
PowerShell.exe "$action = New-ScheduledTaskAction -Execute shutdown -Argument '/s /t 0'; $trigger = New-ScheduledTaskTrigger -At 18:00 -Daily; $options = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -DontStopOnIdleEnd -WakeToRun; $principal = New-ScheduledTaskPrincipal -UserId 'NT AUTHORITY\SYSTEM' -LogonType ServiceAccount -RunLevel Highest; Register-ScheduledTask -TaskName AutoPowerOff -Trigger $trigger -Action $action -Settings $options -Principal $principal"
|
|
ECHO Auto shutdown enabled
|
|
PAUSE
|
|
) ELSE (
|
|
ECHO Please run this script as administrator
|
|
PAUSE
|
|
) |