Util.ShellExecAdmin() Method

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

Syntax

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

The method syntax has these parts:

Part Description
Program (String) 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

This variant of Util.ShellExec() causes an "elevation" request to appear requiring the user's intervention. If the user accepts, it then provides privileged access level to the program that is run.
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.

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.