Super User is a question and answer site for computer enthusiasts and power users. 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

Possible Duplicate:
How to make TaskScheduler fail when the task returns result different from 0

I have a windows task scheduled that runs a console application (.exe file) i have written. I have set the task to retry after 5 minutes up to 3 times on failure.

The task scheduler always see's the task as completed successfully. Even when the application throws an exception.

Is there a way to return something from the application when an exception is thown to tell the task that it has failed. For example and ExitCode?

Or, is there a better way to set up the task so I can tell it there has been an error?

share|improve this question

marked as duplicate by allquixotic, 8088, Karan, Everett, Ƭᴇcʜιᴇ007 Jan 12 '13 at 4:45

This question was marked as an exact duplicate of an existing question.

If possible, you could try to set up another scheduled task, a few minutes later, that would check whether the previous task has had the desired effect (checking whether X is running correctly, whether X variable is worth what you want, whether X file's last modification is today, etc.) and if not, do the same task as the first.

My guess is that the "retry on failure" feature is "if the task scheduler couldn't launch the task". If it did, and the program it launched bugged, "it's not its problem". You ask it to launch, and it launches, period. That's the way I understand it.

So I think your best way is to set up one or more additional tasks that will run a check.

If what you're doing (say, upload a file) is not checkable directly, then you can try to tell the app you launch, if possible, to log each of its results or dates for successful operations.

If not possible, perhaps there are other apps that can monitor a program and output what it does. App which you would launch with the first task as well. It gets complicated, but. :/

share|improve this answer

Not the answer you're looking for? Browse other questions tagged .