Server 2008 issue running batch file

batchbatch-filescheduled-tasktask-schedulerwindows-server-2008

For the life of me, I can't seem to get a batch file running in Server 2008 Task Scheduler, despite it not having the common problems I've seen before.

Problem so far:

  • I have a batch file that takes a hotcopy backup of some repositories and ZIPs them. I am able to run this manually.
  • I have created a task in the task scheduler to call the batch file (no quotes, no command-line args).
  • No matter what, the task returns with Code 0x1 (which I believe has something to do with permissions).

Troubleshooting steps so far:

  • Ran the task manually. Runs perfectly.
  • Made sure I didn't have quotes in arguments due to the 2008 Server hotfix bug outlined previously on ServerFault. I have not only no quoted arguments, but no arguments.
  • Redirected output to a log file to see if it was running. It isn't.
  • Changed the user from the System Service account to the local Administrator account for testing purposes. The Administrator account has all necessary rights & privileges, and is currently logged on when trying to run the task manually.
  • Created another batch file which does nothing but call the other batch file to see if it was somehow maybe a command in the batch file that is initially called. This still fails, but again works if run manually.

I'm at a dead end. Any new thought that could jump-start the troubleshooting process? Thanks!

Edit 1: To clarify, I should note that I'm checking "run task whether user is logged on or not", but I do not remember if it was set up that way initially.

Best Answer

I have the same problem. This is what I checked. What is the name of your batch file? Could it be a .bat? Try renaming it to .cmd SQL Server agent is running the job. Does the service account for that service ha rights? Do you use a call statement or do you just write the name of the batchfile? I think you do not need a call statement (you mentioned it). Is the owner of the job sa. This is normal today. Do you have any net use commands or copy del etc that needs /Q /Y or other statements? The job cannot answer any questions like there are open files are you sure etc. Is there a windows firewall involved? My gotcha was: I tried to do more than one thing in the job. Don't. Rename one thing with one job. Rename another thing with another job. Don't do more than one thing with each job. Sounds stupid I know, but you should do it anyway for troubleshooting purpose. easiest way to test something is net use z: \server\share and see what you get in the event viewer and job history log. Keep it simple then enter a real command. I am very sorry it does not work like it did before when it was top-of-the-line.