Runs an executable program.
The
Shell function has two parameters:
app
The name of the program to be executed. The name of the program in app must include a .PIF, .COM, .BAT, or .EXE file extension
or an error occurs.
style
The number corresponding to the style of the window. It is also optional and if omitted the program is opened minimized with
focus.
Window styles:
|
• |
Normal with focus 1,5,9 |
|
• |
Minimized with focus (default) 2 |
|
• |
Normal without focus 4,8 |
|
• |
Minimized without focus 6,7 |
|
• |
Return value: ID, the task ID of the started program. |
Example
' This example uses Shell to leave the current application and run
' the Calculator program included with Microsoft Windows; it then
' uses the SendKeys statement to send keystrokes to add some numbers.
Sub Main()
Dim I, X, Msg ' Declare variables.
X = Shell("Calc.exe", 1) ' Shell Calculator.
For I = 1 To 5 ' Set up counting loop.
SendKeys I & "{+}", True ' Send keystrokes to Calculator.
Next I ' to add each value of I.
AppActivate "Calculator" ' Return focus to Calculator.
SendKeys "%{F4}", True ' Alt+F4 to close Calculator.
End Sub