Runs a program via the Windows ShellExecute command


ShellExecute (program-name, params, directory, display mode, operation)


(s) program-name: the name of the desired .EXE, .COM, .PIF, .BAT, .CMD file or a data file.

(s) params: optional parameters as required by the application.

(s) directory: current working directory (if applicable).

(i) display mode: @NORMAL, @ICON, @ZOOMED, @HIDDEN, @NOACTIVATE or 0 for the default mode.

(i) operation; operation to perform on the specified file.


(i) @TRUE on success; @FALSE on failure.


This function uses the Windows ShellExecute API to launch the specified file. The similar RunShell function also uses the ShellExecute API in the 16-bit version, but uses the CreateProcess API in the 32-bit version. Note that RunShell has a "wait" parameter, while this function does not.

The @NOACTIVATE value causes the targeted application's window to be displayed in its most recent size and position but without making the application's window the active window when another top-level window is already active.

"operation" is the operation to perform on the file ("Open", "Print", etc.), which may or may not correspond to an available "verb" on the context menu for the file. This parameter may be case-sensitive. Specify a blank string "" for the file's default operation.

Note: If you use this function to launch a shortcut, and the shortcut points to an invalid path, Windows will display a "Missing Shortcut" dialog box asking if you wish to update the shortcut. This would not be suitable to use in unattended operation. Instead, you could use one of the Run.. functions to launch the shortcut, which would return an error #1932 if the shortcut could not be launched. This error can be trapped using the ErrorMode function.

Special Notes:

On Windows 8 and newer, if logged in as administrator, running WinBatch with full administrative execution level (default) and trying to run a process requesting AsInvoker, the process will be run with full Administrative execution level. This is due to restrictions in Windows 8.    


; launches a shortcut to a "Dial-Up Networking" item on the desktop
ShellExecute(StrCat( startdir,"netcom.lnk"), "", "", @NORMAL, "")
WinWaitClose("Connect To")
Message("ShellExecute"," Executed.")
See Also:

RunShell, RunWithLogon, ShellExecuteWait