Windows Task Scheduler does not start VBScript during installation "Run if enabled or not"

I am trying to run a .vbs file as a scheduled task using Windows Task Scheduler. On the General tab, when I select Run only when user logs in, the script runs as expected.

However, when I select "Run whether user was enabled or not" and enter the appropriate credentials, the task runs at the scheduled time, but the script doesn't actually run. I've already tried running the script under wscript.exe as well as cscript.exe but no luck with that.

EDIT: Even if I am logged in when I run the task, the script still won't work under the Login or Logout setting.

Additional information: The purpose of this scheduled task is to run before I arrive at work. I have already configured my BIOS to start at the specified time (06:00) and set the task scheduler at 06:27. I have successfully tested starting the BIOS as well as the script itself (including using the task scheduler to start it). So the only weak link I can find is the option "Run if user is logged in" or not.

I am running Windows 7 Enterprise.

Any help would be appreciated!

+3


source to share


1 answer


This is because it usually runs the script using a shell handler, which is by default wscript.exe

. When there is no desktop environment (since no one is logged in) it will fail and abort the script execution (or rather, it won't run the script in the first place).



To fix this, instead of directly running the .vbs file, modify it to run cscript.exe

(command line program script) with the script file name passed as the first argument. Also make sure you have no calls InputBox

or MessageBox

(use instead WScript.Echo

to return messages to the user: wscript

displays message boxes, but cscript

will log it to the console.

+4


source







All Articles