Hey I'm Lee. My blog was put up to house my strange thoughts, ramblings, nuggets of information I can refer back to and document my learning curves on new dev stuff and fitness regimes.

All thoughts and comments on here are my own, and in no way reflect my employer - I also take no responsibility for spelling, grammar, terminology, accuracy of facts etc... So read at your own risk!

Win 2008 Task Scheduler With Return Code 1 (0x1)

I recently had the most infuriating issue with a scheduled task on a Win 2008 R2 server.

All I wanted it to do was run a .bat file once a day which fired a WGET script. If I logged into the server and clicked the bat file, it fired and triggered the WGET script and everything worked.

But whenever I tried to run it from the Task Scheduler (Either manually pressing run or letting it fire off the schedule), it failed and returned the code 0x1

I checked the history and log and it said it successfully completed with the following:

action "C:\Windows\SYSTEM32\cmd.exe" with return code 1

Great bit of information! Anyway, I spent quite some time changing permissions and users to no avail. I managed to make it work in the end, but its still not completely obvious to me why this makes a difference.

Instead of putting the full file path in the program/script textbox, use the Start in (Optional) field to put the folder that the .bat file is actually in - Like so:


Once you have done this, make sure you tick the 'Run with highest privileges' tick box



And that's it. Its now returning the correct result code 0x0 and my script is running! Finally.

Back to top