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?
Click the Start button, and then click Run. In the Open field, type the full path of the script, and then click OK. You can also type WScript followed by the full name and path of the script you want to run.
Because VBScript is part of the operating system, it will follow the same life cycle as the operating system with which it ships. Therefore, VBScript will at least be supported as long as Windows 7 and Windows Server 2008 R2 are. If it ships in Windows 8, it will be supported as long as that operating system.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With