We have a scheduled task that sometimes hangs. It just stops responding. On Windows 2003, we had task scheduler configured to kill the task after 3 hours. It's a 32-bit process.

On Windows 2008 R2, we've set "Stop the task if it runs longer than" and "If the running task does not end when requested, force it to stop".

However, when the task hangs, it is never stopped, and stays in process explorer for days.

Any clue why Windows Scheduler would not kill a process?

(This post has a reproducible setup for this issue.)

  • What's the real question here? – HopelessN00b Aug 24 '12 at 15:30
  • @HopelessN00b: Why does Win2008 not kill a scheduled task when it has run longer than the "Stop the task if it runs longer than" setting? – Andomar Aug 24 '12 at 15:47
  • Because it tried, and failed for any number of reasons. There's no one reason, but it can be that it lacked permissions, the task failed to respond to the termination signal, the task was waiting on user input, locked by kernel resources, hung waiting on kernel resources, etc... – HopelessN00b Aug 24 '12 at 16:13
  • @HopelessN00b: The task does not respond to anything-- it's stuck. Why does Win2008 not kill it (end process) like Win2003 did? – Andomar Aug 24 '12 at 16:51
  • See my previous comment? – HopelessN00b Aug 24 '12 at 17:12

The answer is that the 64-bit task scheduler will not actually kill a 32-bit task.

We solved this by running pskill as action 1 of the scheduled task. pskill has no problem dispatching a 32-bit processes.

  • I think I'm missing something here. How does having pskill as the first Action of a task enable the scheduler to kill the task if it times out? – Kit Roed Mar 19 '14 at 14:00
  • @KitRoed: Say a task hangs. Then when the next scheduled run comes around, the first action will kill the hanging task. – Andomar Mar 19 '14 at 15:01
  • 1
    Thanks for clearing that up. I may be able to use that approach, +1! – Kit Roed Mar 19 '14 at 16:06
  • nice @Andomar. you asked and solved your own question – user421501 Jun 21 '17 at 22:30

Immediately below the "Stop the task if it runs longer than" is an option that says "If the running task does not end when requested, force it to stop". Is that 2nd option checked?

  • Yes, that option is checked (as mentioned in the question) – Andomar Aug 31 '12 at 9:10
  • Man, I must have not been paying attention. if you launch it manually and kill it manually using the task scheduler GUI, do you get any kind of indication as to why it refuses to stop? Might be a gui popping up asking you "are you sure?". Another think you might be able to do is run taskkill and kill the task by name.. – MikeAWood Aug 31 '12 at 21:39
  • I've attached a debugger to the task, and it's hanging in a third-party DLL. It does not respond to anything. The question is why Task Scheduler doesn't kill it, using TerminateProcess, which kills a process no matter what – Andomar Sep 1 '12 at 9:05
  • Is it launching the DLL as a seperate child thread? Its possible that its not ending the task because it is only killing the parent task and not the child. for instance, you would use "taskkill /T processname.exe" to kill the parent and child processes. Though I would expect the taskscheduler to kill child processes as well. Very curious. – MikeAWood Sep 4 '12 at 20:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.