I am trying to automate a VBScript by using Windows Task Scheduler. However, I tried to use cscript.exe
+ "C:\...\script.vbs"
but it didn't run. I also tried to directly run the same command in CMD (cscript.exe "C:\...\script.vbs"
) and it worked.
What might be the problem?
EDIT :
I just tried to switch the setting 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 make my task scheduled run even when the user is logged off.
Write a batch file like this:
Then schedule the batch file instead of the vbs. That will allow you to see what is happening that is preventing it from running. Any error that you would have seen executing in the console (CMD), will be instead output to that log file between "Started!" and "Stopped!"
What's the hassle all about? I don't use .cmd/.bat and script works! (Windows7 here)
My VBS script (as a scheduled task) runs well on any scenario of these 4:
It's only that on the 1st scenario I encounter the black command window flashing on my screen.
Action settings:
or
My script, which simply creates a file:
After hours of research, one of Blake Morrison (from Microsoft)'s blogs came up; it mentioned that
see Help! My Scheduled Task does not run…
That blog also explains a lot of rules/tips when using Task Scheduler.
So please create a .cmd/.bat file that calls for your VBScript. For example:
cscript.exe YourScript.vbs
would be in your .cmd/.bat script.Have experienced more than once that a VBScript running as planned task worked fine for months and years but suddenly would not work any more despite nothing was changed. Have tried to reactive the task using all the recipes given here and elsewhere, but no success. My workaround was to create a new planned task with all settings copied from the original one.
The .vbs file is running invisibly, which is a consequence of running it with the 'logged on or not' option.
You will not be allowed to interfere with a user using the computer, which means you will be able to help yourself, but not others.
Please read the following text from the Task Scheduler Help menu:
Task Security Context
Greg answered this https://superuser.com/a/816073
Basically you need to create 2 folders:
You have to create a folder (or two on a 64bit-windows):
(32Bit, always) C:\Windows\System32\config\systemprofile\Desktop
(64Bit) C:\Windows\SysWOW64\config\systemprofile\Desktop
Fixed the issue for me (and I could point to the .vbs file, not bat needed).