Programming with Reflection

image\rwnprg32.gif Shell method


Syntax object.Shell Application, [CommandLine], [WindowState], [Wait]



Launches an application, or opens a file in an already running application. You can use this method to start an application using the name of an executable file (*.exe, *.com), a file name associated with a particular application (*.doc, *.bmp, *.txt, and so forth), or a text string associated with a particular application (such as http or ftp). This method returns an error if Reflection cannot locate a file specified in the Application argument, or if the file is not associated with an application.


Application Argument type: String
A string that identifies an application. The string can be:

· The name (or complete path) of an executable file. For example, this command launches a new session of Reflection for HP using the name of the executable file:

Session.Shell "R1win.exe"

· The name (or complete path) of a file associated with a particular application. Depending on the application, the Shell command may open a file into an existing copy of the application or it may launch a new copy. For example, this command launches a new session of Reflection for HP using the name of a settings file:

Session.Shell "My Settings File.r1w"

· A text string associated with a particular application. For example, this command locates the web page with the specified URL, launching your browser if necessary:

Session.Shell ""

CommandLine Argument type: String
Use this optional string to specify command line arguments. For example to start Reflection for UNIX and OpenVMS and open a settings file using the /S command line switch:

     Session.Shell "C:\Mypath\R2win.exe", "/S ""C:\Mypath\MyFile.r2w"""

 WindowState Argument type: Enumeration
Specifies the window state for running the application. If you omit this argument, the application uses the default window size.


 Run the application in a maximized window.


 Run the application in a minimized window.


 Run the application using the current default size.

Wait Argument Type: Boolean
Specifies whether the procedure should wait until an application launched by the Shell method is terminated. If this argument is False or if you omit the argument, the procedure will continue running. If it is True, procedure execution pauses on the Shell command until the launched application is closed. The Shell command does not wait for an application to close if Shell opens a document file into an already running copy of an application.


Note: To use the Shell method to run a DOS command, use the command shell program name (either Cmd.exe or Command.exe) as the Application argument, and the DOS command for the CommandLine argument. For example, the following command will create a new folder:

 Session.Shell "Cmd.exe", "md ""Test Folder"" "

The following sample uses a /k switch which causes the DOS window to remain open after the command is completed:

 Session.Shell "Cmd.exe", "/k dir"

Some versions of Windows support Command.exe, but not Cmd.exe. The command line switches available for these two shell programs differ somewhat. For example, Command.exe does not support the /k switch used above. To see the switches available for each, type the following into a DOS window:

 Cmd /?

 Command /?


image\jump.gif Keyword Index

image\popup.gif Related Topics

image\popup.gif Reflection products that use this command