My script won't run under the task scheduler. Why?

GordyII picture GordyII · Mar 20, 2009 · Viewed 81k times · Source

I have a vbscript script that I runs fine when I am running it myself.

For some reason, when I run it under the task scheduler as an administration user, it runs, but doesn't even write to my log file. It shouldn't be permissions, as the user I run it under is adminstrator.

Its a script calling 32 bit dlls on a Win2008 64 bit machine.

C:\windows\SysWOW64\cscript.exe Bob.vbs

I also set the local directory to where I run it from.

Ironically the task scheduler says that "successfully finishes" running the task.

Also, there are other scripts in the task scheduler running fine, its just this script.

Does anyone have a list of things that I can check?

Answer

Patrick Cuff picture Patrick Cuff · Mar 20, 2009

I had a similar problem running a scheduled task on my SVN server.

My script was writing to what I thought was the current working directory (the directory I specified for the task as the "Start in" folder). If I logged onto the server and ran the script it worked fine. When running as a scheduled job it wouldn't.

In my case, it looked like the scheduler re-assigned the working directory to be the directory specified in the TEMP environment variable for the user account used to run the job, not the directory I specified for the task (the "Start in" folder).

Check the TEMP folder for the account and see if your files are there.