How can I run a program in a script?

You cannot run programs directly in an ActiveX script however if you have Microsoft's Windows Script Host (WSH) installed you can tell WSH to run it for you.

The following VBScript statements use WSH to start Internet Explorer with a command-line argument:

Dim shell
Set shell = CreateObject("WScript.Shell")
shell.Run """C:\Program Files\Internet Explorer\IExplore.exe""http://www.vandyke.com"

Here's the same thing in JScript:

var shell = new ActiveXObject("WScript.Shell");
shell.Run("\"C:\\Program Files\\Internet Explorer\\IExplore.exe\"http://www.vandyke.com");

Note, the Run() function uses whitespace to separate program names from possible command-line arguments. In order to deal with paths with spaces it is necessary to add extra quotes in both languages to make it clear.

For information and downloads related to WSH look for the "Windows Script Host" section at:

http://msdn.microsoft.com/en-us/library/ms950396.aspx

Was this information helpful?
Yes No

Thank you!
Send your comments and questions to VanDyke Software Support,
or join the discussion in the VanDyke Software Forums.

Can't find the answer you're looking for?
Ask VanDyke Software Support directly
and we will get back to you as soon as possible.

   

VanDyke Software uses cookies to give you the best online experience. Before continuing to use this site, please confirm that you agree to our use of cookies. Please see our Cookie Usage for details.