Running Applications


When you need your script to launch another application, use WshShell’s Run method:

Run strCommand, [intWindowStyle], [bWaitOnReturn] 

 strCommand 

The name of the file that starts the application. Unless the file is in the Windows folder, you should include the drive and path to make sure that the script can find the file.

 intWindowStyle 

A constant or number that specifies how the application window will appear. These are some of the more useful values:

 
 intWindowStyle 

Window Appearance

 

0

Hidden

 

1

Normal size with focus

 

2

Minimized with focus (this is the default)

 

3

Maximized with focus

 
 intWindowStyle 

Window Appearance

 

4

Normal without focus

 

6

Minimized without focus

 bWaitOnReturn 

A Boolean value that determines whether the application is run asynchronously. If this value is True, the script halts execution until the user exits the launched application; if this value is False, the script continues running once it has launched the application.

Here’s an example:

Set objWshShell = WScript.CreateObject(“WScript.Shell”) objWshShell.Run “CONTROL.EXE INETCPL.CPL", 1, True

This Run method launches Control Panel’s Internet Properties dialog box in a normal-sized window, gives control to the dialog box, and waits for the user to close the dialog box before control returns to the script, which immediately exits.

Note

To learn more about launching individual Control Panel icons using Control.exe, please see Chapter 1, “Mastering Control Panel, Policies, and PowerToys.”




Insider Power Techniques for Microsoft Windows XP
Insider Power Techniques for Microsoft Windows XP (Bpg-Other)
ISBN: 0735618968
EAN: 2147483647
Year: 2005
Pages: 126

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net