Windows – Task Scheduler Idle task not triggered on the correct time window

scheduled-taskstask schedulerwindowswindows 10windows task scheduler

In my windows 10 machine I have created the below task scheduler task and set the trigger time to be 1 min when idle. I've checked and manually timed the trigger to happens and it always triggers after 4 mins when no keyboard or mouse actions, not 1 min. I've manually timed it more than 5 times and it always runs after 4 mins not 1 min. Any explanation? and how I can run it after 1 min of idle time not 4 mins? Also the same task doesn't trigger at all on windows 7 as described here https://superuser.com/questions/1568707/task-scheduler-on-idle-task-not-triggered-windows-7

I've noticed on the Microsoft docs https://docs.microsoft.com/en-us/windows/win32/taskschd/task-idle-conditions that it says something about 4 minutes but I didn't understand and I don't know if it's related or not? and why it doesn't work at all on my windows 7 machine.

enter image description here

Below is how my scheduled task looks in task scheduler:

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

Also here is the xml of my Task:

<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Date>2019-11-20T15:43:06.6081219</Date>
    <Author>MyPC\MyUser</Author>
    <URI>\MyAppIdleTask</URI>
  </RegistrationInfo>
  <Triggers>
    <IdleTrigger>
      <Enabled>true</Enabled>
    </IdleTrigger>
  </Triggers>
  <Principals>
    <Principal id="Author">
      <UserId>S-1-5-21-1004336348-1177238915-682003330-385281</UserId>
      <LogonType>InteractiveToken</LogonType>
      <RunLevel>LeastPrivilege</RunLevel>
    </Principal>
  </Principals>
  <Settings>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
    <AllowHardTerminate>true</AllowHardTerminate>
    <StartWhenAvailable>false</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
    <IdleSettings>
      <Duration>PT1M</Duration>
      <WaitTimeout>PT0S</WaitTimeout>
      <StopOnIdleEnd>true</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>true</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>true</RunOnlyIfIdle>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>PT72H</ExecutionTimeLimit>
    <Priority>7</Priority>
  </Settings>
  <Actions Context="Author">
    <Exec>
      <Command>C:\MyWinFormApp\MyWinForm.exe</Command>
    </Exec>
  </Actions>
</Task>

Best Answer

Microsoft basically programmed Windows to say: A computer is considered Idle if for 4 minutes, no user input was generated.

What this means is this: Windows starts detecting that a system is idle but ignores it for 4 minutes. The exact reason why is unknown, but it is probably for optimization reasons and possible complaints. When the system becomes in Idle state after 4 minutes, the OS announces: the system is now idle for 4 minutes, and counting...

Task scheduler gets the message, sees your task which is set, idle for 1 minute and thinks: Oh, we should've started you 3 minutes ago. Lets start you now. In windows 7, it doesn't care for the 3 previous minutes.

This gives you 2 options.

  1. Accept that there always will be a delay of 4 minutes
  2. Don't use Task Scheduler. Instead create a program or script that measures activity and perform the launching of the task yourself. Do note that this will increase the overhead of the system and may hurt performance if coded inproperly.

My recommendation would be to go for option 1. Just accept that there is a 4 minute delay. Your initial question was 30 minutes anyway.

Related Question