Task scheduler "stop the task if it runs longer than" works only if the task is started by Powershell but not in the GUI. RRS feed

  • Question

  • Hello,

    The "stop the task if it runs longer than" setting is ignored when the task T1 is started by a user in the GUI. The task T1 runs indefinitely. We observed that task T1 runs indefinitely (even more than 40 days), although the setting was active with a default value of just 3 days.

    However, when we use another task T2 with a Powershell script using Start-ScheduledTask to start the task T1, the setting works. Windows stopped the task T1 after 3 days writing this event id on history: 329 "Task stopping due to timeout reached".

    I can reproduce this behaviour on my notebook:
     Task T1 calls the Powershell script:
       Start-ScheduledTask -TaskName T2
     Task T2 has a value of 1 Minute for the setting "stop the task if it runs longer than" and calls the Powershell script:
       Start-Sleep -m 70000
       "hello world!" | Out-File "C:\tmp\test1.txt"

     If I start task T2 it writes "hello world!" on file C:\tmp\test1.txt, although this task should stop after 1 Minute (60000 ms), as the Sleep waits for 70000 ms.

     If I start task T1, than task T2 stopped after 1 Minute, and "hello world!" was not written on file C:\tmp\test1.txt.

    Why is the behaviour not the same on these both call situations (gui or powershell)?

    Is it a bug, or it is a feature?

    Tuesday, July 16, 2019 12:23 PM

All replies

  • Hi,

    Thanks for your question.

    This is indeed a very strange phenomenon. I tested it in my environment and got the same result as you.

    I also tried setting it up using the powershell command below:

    $task = Get-ScheduledTask -TaskName "test"
    $task.Settings.ExecutionTimeLimit = "PT1M"
    Set-ScheduledTask $task

    But I got the same result.

    I will suggest you post this issue in User Voice.

    Best regards,


    Just do it.

    Thursday, July 18, 2019 5:38 AM
  • Hi,

    Was your issue resolved?

    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.

    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.

    If no, please reply and tell us the current situation in order to provide further help.

    Best Regards,


    Just do it.

    Wednesday, July 31, 2019 7:50 AM