I am trying to create a script that I can push out via GPO. The script creates a scheduled task to logoff users when Idle for 4 hours.
The syntax is: schtasks /create /tn <TaskDisplayName> /sc <SchedultType> /I <timer> /tr <task to run> /F
My script code is: schtasks /create /tn "Idle Logoff" /sc onidle /I 240 /tr "shutdown.exe /l /f" /F
The /SC ONIDLE is supposed to start the task when the PC goes idle.
The /I 240 is suppose to set the timer for 240 minutes (4 hours) after idle.
The script works mostly. It creates the scheduled task. The task runs on idle. And the "shutdown /L /F" command works fine.
HOWEVER, it is running IMMEDIATELY when the PC is idle. Not after the PC is idle for 4 hours. When I check the task, the option "start the task only if the computer is idle for" is unchecked, but the value (which is grayed out) says 4 hours.
Is there a switch that I am missing on the schtasks /create which would fix this?
Thanks.