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

84,196

Solution 1

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.

Solution 2

I've had this problem with DOS batch files and VB scripts on Windows 2008 Server and Windows 7. In every case, once I set the "start in" folder for the scheduled task action, everything worked fine.

Solution 3

If you are running Win2008 64 bit machine: this (finally) worked for me on same server. Task scheduler runs a batch file (eg runvbs.bat) to call cscript with a 32bit version of the command line interpreter, like this:

@echo off
%windir%\syswow64\cmd.exe /C "c:\windows\system32\cscript.exe //B //nologo import_some_data.vbs"

Note the double quotes.

I used the Administrators group for permissions and Run with highest privileges.

Configure for: Windows® 7, Windows Server™ 2008 R2

In the Edit Action dialog I have:

Action: Start a program

Program/script: runvbs.bat

Start in: c:\inetpub\wwwroot\asp\importstuff\

Solution 4

I had real problem with this (well a morning) and found this solution here:

In the windows task scheduler I had to click "change user or group" button and add "Administrators" group.

Hope it helps someone.

Solution 5

For Windows 2008 you probably need to ensure that the task runs with administrative privileges.

General Tab - (Check) Run with highest privileges

Share:
84,196
GordyII
Author by

GordyII

Updated on May 04, 2020

Comments

  • GordyII
    GordyII about 4 years

    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?