Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

marked as duplicate by allquixotic, 8088, Karan, Everett, techie007 Jan 12 '13 at 4:45

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer

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
add comment

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