Having a very strange case here, where a windows task scheduler job executes a C# console application at a specific time, that returns -1 in case of an error. The job is configured to rerun itself if an error occurs.

The console app fails and returns the error code. The task scheduler recognizes the return code as 4294967295 (0xffffffff), which is -1 interpreted as a DWORD (unsigned int), claims a successful run and thus does not rerun the failed app.

Is this some kind of bug, where task scheduler is not realizing, that the app is returning a negative number, or am I missing something here?

  • My research suggests that the Task Scheduler does not check the return code at all, and the "failed" option only kicks in if the task fails to start. (Or perhaps if the time limit expires and the task is killed?) I couldn't find any MS documentation though. – Harry Johnston May 18 at 0:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.