Shell (function)

<< Click to Display Table of Contents >>

Shell (function)

Shell(AppName [, Mode])

Starts a program.

The return value is a task ID which identifies the launched program. Values below 32 indicate that launching the program failed.

AppName is the name of the executable file. The name must have one of the following file extensions: .PIF, .COM, .BAT or .EXE.

The optional parameter Mode indicates in which window state the new program should be opened:

Value

Meaning

1

Normal with focus (default value)

2

Minimized with focus

3

Maximized with focus

4

Normal without focus

6

Minimized without focus

See also: AppActivate, AppPlanMaker, AppTextMaker, CreateObject, GetObject

Example:

Sub Main

 X = Shell("Calc.exe", 1)        ' Invoke the Calculator application

 If X < 32 Then

         MsgBox "The calculator could not be started"

         Stop

 End If

 For i = 1 To 5

         SendKeys i & ".+}", True    ' Send keystrokes

 Next i

 Msg = "The calculator will be closed now."

 MsgBox Msg

 AppActivate "Calculator"        ' Set the focus to the calculator

 SendKeys "%{F4}", True          ' Send Alt+F4 to close the application

End Sub