Util.ShellExec() Method

Run an external program, returning its operating system task ID number

Syntax

Util.ShellExec(Program, [CommandLine], [WindowState])

The method syntax has these parts:

Part Description
Program (String) The full path/name of the executable or batch file to run (or using %PATH% for resolution)
CommandLine (String) command line arguments to be passed to the program (default = nothing)
WindowState (ShellWindowState) Optional. The initial state of the program's main window (or the console window if the program is a command-line application, (default minimized with focus, swMinimizedFocus).
Return (Long) task identification number of the external program -- assigned by the operating system

Remarks

NOTE: The ShellExec() method returns immediately after starting the external program. It does not wait for the external program to exit. Use Util.IsTaskActive() to monitor for task exit, and Util.GetTaskExitStatus() to check the Win32 exit status of the task, once it has exited.

For running programs as Administrator (Windows 7/8) use Util.ShellExecAdmin().

Symbolic Constants

The (symbolic) values for ShellWindowState are:

Constant Value Description
swHide 0 The task window is hidden.
swMaximizedFocus 3 The task window is initially displayed maximized and given the focus.
swMinimizedFocus 2 The task window is initially displayed minimized and given the focus.
swMinimizedNoFocus 6 The task window is initially displayed minimized but not given the focus.
swNormalFocus 1 The task window is initially displayed as a normal window and given the focus.
swNormalNoFocus 4 The task window is initially displayed as a normal window but not given the focus.