Why my scheduled task completes with return code 2

I recently had a task job scheduled in one of Windows server 2008 but kept getting a return code 2 every time it runs.

Task Scheduler successfully completed task "\RoomView" , instance "{fcc8337a-11b2-4e69-b101-a58bb8d18ead}" , action "C:\Windows\SYSTEM32\cmd.exe" with return code 2.

Obviously, even though it says Task Scheduler successfully completed task, the task didn’t complete what it supposed to do.

The return code 2, as part of the cmd command exit code, indicates that The system cannot find the file specified, meaning that the file in task cannot be found in specified location.

It doesn’t seem to be the case in the task I’ve scheduled. I had made sure all files are in the location where it belongs. And I can run the task manually outside the task scheduler. The only explanation why the scheduler threw this exit code is probably the security setting. Since I already set the task run under the admin account, I enforced it to run with the highest privileges, the option under General tab in task properties, just like Run as administrator.

image

And bingo, now I am finally getting 0 as the return code now, stating that program successfully completed.

image

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">