Windows Task Scheduler Doesn't Run VBScript

After hours of research, one of Blake Morrison (from Microsoft)'s blogs came up; it mentioned that

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

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.


Write a batch file like this:

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

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:

  1. cscript and option "Run only when user is logged on"
  2. cscript and option "Run whether user is logged on or not"
  3. wscript and option "Run only when user is logged on"
  4. wscript and option "Run whether user is logged on or not"

It's only that on the 1st scenario I encounter the black command window flashing on my screen.

Action settings:

cscript
or
wscript

My script, which simply creates a file:

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