Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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