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?