2

I have an application (.exe) which I am running via a scheduled task on Windows Server 2008 R2. The task runs fine but when the .exe returns a non-zero exit code the task is still successful when it should fail.

I get this message:

Task Scheduler successfully completed task "\CustomerDataSourceETL - Whics" , instance "{a574f6b4-2614-413c-8661-bc35eaeba7cd}" , action "E:\applications\CCDB-ETL\CustomerDataSourceETLConsole.exe" with return code 214794259.

How can I get task scheduler to detect that the return code is > 0 and fail the task?

1 Answer 1

1

I don't think there is anything you can do within Task Scheduler except manually check the 'Last Run Result' column. The event log also creates an informational entry in both cases.

The Task Scheduler in Vista and later comes with a better API than the older ones and you can use it to check for the LastTaskResult of your task.

I wrote a Windows Service that checks all my tasks every hour for any results not 0 and sends me an email if it found any. I could make it available if anybody is interested?

You could do the same with Powershell but then you would need Task Scheduler to schedule that script and you wouldn't get notified if the whole thing is down.

2
  • am interested in the windows service code you wrote...would you mind sharing? thanks!
    – user139453
    Oct 3, 2012 at 10:17
  • @steven - Have a look at this CodePlex project Oct 3, 2012 at 11:19

You must log in to answer this question.

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