How to start a VBS-script in Windows 7 task scheduler with Messagebox?
Solution 1
You should use CScript.exe
over WScript.exe
so that commands like WScript.Echo
will be output to console instead of Dialog Box. As you point out, the scheduled task should avoid MessageBox or any UI elements that could cause your script to block.
I recommend scheduling your script as follows:
C:\Windows\System32\CScript.exe //Nologo //B X:\PathToYourScript\YourScript.vbs
The options I choose for you are "Prevent logo display" and "Batch mode". Consult your online help by running CScript /?
on a Command Prompt.
Solution 2
Just posting this b/c I struggled w/ syntax for a while...
everyone says to use a .bat to run a .vbs in task scheduler...
.bat file NOT NEEDED! but... fine print:
To run vbs from task scheduler - either make a shortcut / .lnk or call directly.
!!NOTE!!
No quotes allowed in file path, no spaces allowed in file path.
Due to this it's often easier to make a shortcut to meet these rules in the cases where the vbs path / name is already set in stone.
Erik
Updated on August 30, 2020Comments
-
Erik over 3 years
I am using Win7 x64 Professional, and try to run a VBS script using the Windows task scheduler. My problem is, that the script behaves totally different than a script started directly, even if I start it with high privilieges, and using the same user.
One thing that I have noticed is for example that it is not possible to output any messagebox on screen.
Under Windows XP, I remember there was an option called "allow interaction with desktop" that fixed a lot of these problems, but I cannot find these options on Win7.
I have also tried to run Wscript.exe, and pass the scriptfile as a commandlineoption, but this results in the script not being started at all, even though task scheduler says it was started correctly.
Can you please explain what is the best way to start a VBS in Win7 in order to have the same behaviour as the script would have if it was started directly in explorer?
-
clarifier over 8 yearsshoul any addition arguments and Start in folder required