2

I have a C# Console application that runs under Windows Task Scheduler.

Should the application fail for what ever reason, I use "Exit Codes" to propagate back to Task Scheduler.

However, no matter what I try, Task Schedule logs always report "Task Completed Successfully".

I have tried the two defined exit strategies.. being...

Environment.Exit(hasError ? -1 : 0);

and

static int Main(string[] args)
{
    ... code ...
   return (hasError ? -1 : 0);
}

Any suggestions what I may be doing wrong

Running app in Windows Server 2012 Standard

20
  • The answer to your question can be found here: stackoverflow.com/questions/16969500/… Commented Jun 11, 2015 at 14:30
  • If did read the one bill but the bit where it say Task Scheduler successfully completed task "\test4" , instance "{a41adae0-a378-45f6-aadc-648d27852042}" , action "C:\blah..blah\Release\WpfApplication1.exe" with return code 55. always says with return code 0 Commented Jun 11, 2015 at 14:36
  • Did you verify that your code (hasError ? -1 : 0) isn't returning 0 even though you may be expecting -1 ? Commented Jun 11, 2015 at 14:38
  • I've put test code in to just return (64) and it still says with return code 0 Commented Jun 11, 2015 at 14:44
  • instead of return(64) try doing Environment.Exit(64) directly? Do you get the same return code when running the app manually? Commented Jun 11, 2015 at 14:47

1 Answer 1

0

Turns out its a Windows 2012 Server issue and requires the following hot-fix

https://support.microsoft.com/en-us/kb/3003689

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.