windows 2008 task scheduler return code 1, no logging

Tiberiu picture Tiberiu · May 24, 2011 · Viewed 11.1k times · Source

trying to run a simple batch file in windows 2008 task scheduler

call cleanup.bat > cleanup.log;
call ant -f ongoing_changes.xml > automation.log

The action is triggered properly and from the History logs (7 information messages) this seems to be puzzling

Task Scheduler successfully completed task "\Run regression" , instance "{edbd26d2-b71b-43d6-960f-29c31e39493c}" , action "C:\Windows\SYSTEM32\cmd.exe" with return code 1.

Unfortunately nothings gets executed (as no logs are created), even if I trigger manually the task, of course the batch file runs fine if executed from OS. If I don't use "call" in the batch file, then "return code 0" is presented, still nothing gets executed.

Answer

Tiberiu picture Tiberiu · Jun 7, 2011

First I had to convert the task scheduled to be "Windows server 2003, Windows Xp or Windows 200" then I managed to debug this putting a

"call timeout 5"

at the end of the script and figured out that ant environment wasn't properly loaded, thus commands were failing.