Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 500
GordyII Avatar asked Mar 20 '09 04:03

GordyII


People also ask

Why is Task Scheduler not running my task?

If the Task Scheduler stops automatically or is not running on your Windows 10 system, you need to do the following things: Check and start Task Scheduler service. Change the Service configuration. Start Task Scheduler using Command Prompt.

How do I schedule a script to run automatically?

Method 2: Using Windows Task Scheduler. Step 1: Open Task Scheduler Application on your Windows Machine. Step 2: Click on 'Create Basic Task…. ' in the Actions Tab. And give a suitable Name and Description of your task that you want to Automate and click on Next.


3 Answers

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.

like image 154
Jared Avatar answered Sep 21 '22 13:09

Jared


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.

like image 32
Patrick Cuff Avatar answered Sep 21 '22 13:09

Patrick Cuff


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\

like image 32
Arbor Avatar answered Sep 20 '22 13:09

Arbor