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.