5

I'm trying to run a task hourly with the Task Scheduler to launch a bat file, but it is not working. Looking at the history, I see the following which looks to be the issue:

Task Scheduler successfully completed task "\Random" , instance "{c19041aa-939d-4876-a12d-456fc3e632ce}" , action "C:\Windows\SYSTEM32\cmd.exe" with return code 1.

What does return code 1 mean for cmd.exe? How can I get more verbose debugging information? My task worked at first, but then it stopped after a couple days.

3
  • Does the batch file work if you run it manually? – Karan Nov 30 '12 at 0:48
  • 1
    Try setting the starting folder to see if it works. – Luiz Angelo Nov 30 '12 at 1:40
  • Yes, batch file works correctly when run manually. – WilliamKF Nov 30 '12 at 12:10
4

https://blogfodder.co.uk/posts/win-2008-task-scheduler-with-return-code-1-0x1/

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.

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.

1

If your batch file uses Robocopy it might just be the exit code for that. In robocopy nonzero errorlevel doesn't necessarily mean that something went wrong.

These might be informative in such cases:

https://ss64.com/nt/robocopy-exit.html

https://blogs.technet.microsoft.com/deploymentguys/2008/06/16/robocopy-exit-codes/

This won't really help OP anymore, but I'm posting this here because this page was in the top results of the searches I made while researching for solutions for similar issue.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.