On a Windows 2008 Server I have a scheduled task which is configured to restart if the task fails. Everything works fine if the command succeeds.

However, if the command runs and returns a failure exit code (non-zero), the task does not restart.

Am I missing something? How do I get the task to restart if the command returns a failure code? Isn't this what the "restart on failure" setting supposed to do?


It appears this is by design. It looks like the "restart on failure" setting means to restart if the task scheduler for some reason cannot start the action command (e.g. login failure, ACL issue, etc). If the command is started successfully the task scheduler considers it successful, it doesn't care about the exit code.

I guess one way to work around this is to wrap the command in a script has the retry logic if it fails. Or use a different scheduler as someone suggested.

  • That's idiotic, Microsoft. Thanks for the info!!!! – Pecos Bill Feb 13 '15 at 23:29

As far as I've ever been able to tell, this is designed behaviour. I've never been able to make it continue. I recommend springing for a better task scheduler (i.e. visualcron or similar) or setting your task up to run as a service.

Task scheduler 2.0 is better, but I think it STILL dies if the job never succeeds...So if you tell it to retry 100 times, and it can't make it work, it won't try again the next time.

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.