This repository has been archived on 2023-05-21. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
SysTools/InstallTools/Enable-AutoPoweroff.cmd
2021-12-01 14:55:23 +00:00

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
)