views:

1483

answers:

4

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?

A: 

I've had similar problems in the past with code not executing when scheduling vbs scripts - it can be problematic! Also curious to see if anyone can solve this. (by the way, we solved it by rewriting the code as a C# console application)

Chris
C# would be much better than mucking around with VBScript. I will have to suggest that to the boss :)
GordyII
The only problem I ever had was trying to run the VBS files directly (no parameters got passed through). That was solved by using cscript, which is obviously not the case here. Still, SysWOW64 interaction is what I'd be looking at.
paxdiablo
A: 

When I've had this problem it's usually because the program running on my task is erroring out, even though the return value of the completed task didn't report any problem.

You say it runs but doesn't write to your log -- is it possible it's crashing before it writes to your log?

If you haven't already, add error handling to your script and try to log any errors, or at least try to trace how far through the script it's getting.

Jay Riggs
A: 

Where are you trying to write too? Hopefully not any network drives which wouldn't be present for the administrator.

Are you able to simply login as administrator and trying to run the script to see what errors you get?

Are you depending on any path or other environment settings that wouldn't be present for the administrator?

Zoredache
+2  A: 

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.

Patrick Cuff