Windows Task Scheduler Doesn't Run VBScript

I am trying to automate VBScript using the Windows Task Scheduler. However, I tried to use cscript.exe + "C:\...\script.vbs" , but it did not start. I also tried to directly run the same command in CMD ( cscript.exe "C:\...\script.vbs" ) and it worked.

What could be the problem?

EDIT:

I just tried switching the parameter to "Run only when user is logged on" from "Run whether user is logged on or not" and it worked. I am wondering if there is a way to do the scheduled work of my task, even when the user is logged out.

+6
source share
6 answers

After several hours of research, Blake Morrison's blog (from Microsoft) appeared; he mentioned that

If you are running a .vbs / .ps1 script, try running it from a .cmd / .bat script

see Help! My scheduled task does not start ...

This blog also explains a lot of rules / tips when using the Task Scheduler.

So create a .cmd / .bat file that calls your VBScript. For example: cscript.exe YourScript.vbs will be in your .cmd / .bat script.

+4
source

Write the batch file as follows:

 echo "Started!" > c:\foldergoeshere\log.txt cscript.exe "C:\...\script.vbs" > c:\foldergoeshere\log.txt echo "Stopped!" > c:\foldergoeshere\log.txt 

Then plan the batch file instead of vbs. This will allow you to see what is happening, what is stopping him from working. Any error you saw in the console (CMD) will be displayed in this log file between "Started!" and "Stop!"

+2
source

What a hassle? I do not use .cmd / .bat and the script works! (Windows7 is here)
My VBS script (as a scheduled task) works well in any of these 4 scripts:

  • c script and the parameter "Run only at user login"
  • c script and the parameter "Run whether the user is logged in or not"
  • w script and the option "Run only at user login"
  • w script and the parameter "Run whether the user is logged in or not"

Only in the first scenario do I encounter a black command window blinking on my screen.

Action Settings:

cscript
or
wscript

My script that just creates the file:

 Set objFSO = CreateObject("Scripting.FileSystemObject") filename = "C:\Temp\" & Hour(Time) & Minute(Time) & Second(Time) Set objFile = objFSO.CreateTextFile(filename) 
+2
source

The .vbs file runs invisibly, which is the result of running it with the "logged on or not" parameter.

You will not be allowed to interfere with the use of the user using a computer , which means that you can help yourself, but not others.

Read the following text in the help menu of the task scheduler:

Task Security Context

You can specify that the task should be performed even if the account under which the task is scheduled to run does not register when the task starts.

To do this, select the radio button labeled "Run" whether the user is logged in or not.

If this switch is selected, tasks will not be executed interactively.

To complete the task interactively, select "Run" only when the user is registered on the radio button.

+1
source

More than once faced with the fact that VBScript, working on a scheduled task, worked perfectly for several months and years, but suddenly did not work anymore, despite the fact that nothing has changed. We tried to respond to this problem using all the recipes given here and elsewhere, but without success. My workaround was to create a new scheduled task with all the settings copied from the original.

0
source

Greg answered this https://superuser.com/a/816073

Basically you need to create 2 folders:

You must create a folder (or two on 64-bit windows):

(32 bits, always) C: \ Windows \ System32 \ config \ systemprofile \ Desktop

(64 bit) C: \ Windows \ SysWOW64 \ config \ systemprofile \ Desktop

Fixed the problem for me (and I could point to the .vbs file, not bat).

0
source

All Articles