Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 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.

share|improve this answer
    
am interested in the windows service code you wrote...would you mind sharing? thanks! –  user139453 Oct 3 '12 at 10:17
    
@steven - Have a look at this CodePlex project –  Peter Hahndorf Oct 3 '12 at 11:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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