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

后端 未结 13 2353
忘掉有多难
忘掉有多难 2021-02-04 08:53

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 do

相关标签:
13条回答
  • 2021-02-04 09:12

    Looked all over to figure this out, but now that i got i will share.

    Had scripts that ran fine on server 2003, trying to move to server 2012 and a portion of the script would not run.

    Had to create a new task and on general tab select configure for "windows server 2003, Windows XP or Windows 2000. This option does not allow for 2003 if you use a basic task, you have to use new task.

    0 讨论(0)
  • 2021-02-04 09:13

    I had the same problem.

    I fixed it by using relative path ("logs\log") instead of the absolute I was using before ("U:\workingDirectory\logs\log").

    Aparently when you execute scripts via task scheduler you need to use relative paths.

    0 讨论(0)
  • 2021-02-04 09:13

    I've had same issue. Used next string in Task -> Run field CMD /C "full path to my VBScript" like CMD /C c:\Test\MyScript.vbs

    0 讨论(0)
  • 2021-02-04 09:15

    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\

    0 讨论(0)
  • 2021-02-04 09:15

    Solved this same issue. Script would fail when connecting to database then after fixing that it failed when creating Xls file. I created a bat file and added the below contents to it. this bat file will call my vb script and run it in 32 bit mode.

    %windir%\SysWoW64\cmd.exe /C "c:\windows\system32\cscript.exe //B //nologo C:\ScheduledJobs\PrimeReconDev\myVBScript.vbs"
    

    I set up the task schedule to execute my the bat file with the above contents and sect the executing user to Administrators. Do this by sing the "change user or group" option on the general tab. once done I was able to execute successfully no issues. i was initially executing as me and I am in the administrators group but it was still failing. Executing as built in administrators did the trick

    0 讨论(0)
  • 2021-02-04 09:19

    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.

    0 讨论(0)
提交回复
热议问题