Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Task Scheduler Doesn't Run VBScript

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.

like image 931
lovechillcool Avatar asked Apr 16 '15 00:04

lovechillcool


People also ask

How do I enable VBScript in Windows 10?

Group Policy settingsSelect Group Policy Object (GPO), and then right-click and select Edit. Double-click and edit the Allow VBScript to run in Internet Explorer setting. Click Enabled to enable the policy. Under policy Options, select Enable from the list.


2 Answers

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).

like image 129
Curtis Avatar answered Oct 05 '22 05:10

Curtis


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.

like image 43
lovechillcool Avatar answered Oct 05 '22 04:10

lovechillcool