Client Management Suite

 View Only

Running VBS Scripts Through Software Delivery 

Jul 01, 2007 09:00 PM

I first noticed a problem when running a Software Delivery job using a Visual Basic script and the status of the tasks always showed "Run completed asynchronously". On closer inspection I noticed that the program was actually hanging in the background.

Read on to learn the steps I took to troubleshoot (and overcome) this problem.

Troubleshooting

To test, I set up a VB script to run as system account in a hidden window. I tested the file by double-clicking and watching it run through completely. A pop-up notified me of the success.

My command line for the program was:

wscript "myscript.vbs"

I had chosen wscript as this is Microsoft's default association.

The problem was that wscript is the GUI (graphic user interface) version of WSH. Most Windows operating systems default to using wscript when executing a script. Therefore, if you double-click a .vbs script, most likely it will run using the wscript.exe version of WSH. This will send all output directly to the screen in the form of message boxes. Alternatively, you can force the use of wscript by typing the following in a command prompt window:

wscript.exe scriptName.vbs 

The problem with this is that the output is sent to a GUI screen usually in the background and no return code is sent to the Altiris Agent until that window is closed. This window will not close without human intervention and the next time the computer restarts, a "Run completed asynchronously" status will show.

As there is quite a bit of output in the VBS script I did not want to have to edit the file to strip out all write lines.

Resolution

The resolution for this problem (that saved me a lot of time) is to use cscript. Cscript is the command-line version of WSH. cscript allows slightly more control over your scripts and is typically the preferred method for administrative scripts. You can use cscript by typing the following at the command prompt:

cscript scriptName.vbs 

Using cscript causes all output to be sent to the command prompt window, thus allowing you more control over the output, and prevents you from having to respond to every message that is displayed (which is the case when you use wscript). This will complete the program and send a exit code to the Altiris Agent.

After changing the command line to:

cscript "myscript.vbs"

I was able to have my job work as desired.

So if you desire to hide all output and run the VBS script hidden, you will need to use "cscript", however if you need the output from the VBS script to display for the user then use "wscript".

Hope this helps.

Statistics
0 Favorited
0 Views
0 Files
0 Shares
0 Downloads

Tags and Keywords

Comments

Jul 04, 2007 09:45 AM

You could always wrap the VBS in a wise script by using the Execute VBS Script function. This way, your SWD Package is now an EXE, and the script cannot be tampered with by the User.

Jul 02, 2007 11:54 AM

I ran into the same problem when trying to authenticate when mapping network drives outside the domain.
Using cscript resolved that for me as well.

Related Entries and Links

No Related Resource entered.