# Function Reference

# ShellExecute

Runs an external program using the ShellExecute API.

ShellExecute ( "filename" [, "parameters" [, "workingdir" [, "verb" [, showflag]]]] )

## Parameters

filename | The name of the file to run (EXE, .txt, .lnk, etc).
parameters | [optional] Any parameters for the program. Blank ("") uses none.
workingdir | [optional] The working directory. Blank ("") uses the current working directory.
verb | [optional] The "verb" to use, common verbs include: $SHEX_OPEN ("open") = Opens the file specified. The file can be an executable file, a document file, or a folder $SHEX_EDIT ("edit") = Launches an editor and opens the document for editing. If "filename" is not a document file, the function will fail $SHEX_PRINT ("print") = Prints the document file specified. If "filename" is not a document file, the function will fail $SHEX_PROPERTIES ("properties") = Displays the file or folder's properties See remarks for more information on the default behavior when a verb is not specified. Constants are defined in "AutoItConstants.au3".
showflag | [optional] The "show" flag of the executed program: @SW_HIDE = Hidden window @SW_MINIMIZE = Minimized window @SW_MAXIMIZE = Maximized window

## Return Value

Success: | the PID of the process that was launched. Or -1 if there was no PID available.
Failure: | 0 and sets the @error flag to non-zero.

## Remarks

After running the requested program the script continues. To pause execution of the script until the spawned program has finished use the ShellExecuteWait() function instead.
When no verb is specified the default verb is used. The default verb is the verb configured in the registry. If no verb is set as default in the registry then the "open" verb is used. If the "open" verb is not present then the first verb listed in the registry is used.

## Related

Run, RunAs, RunAsWait, RunWait, ShellExecuteWait

## Example

    #include <MsgBoxConstants.au3>

    Example()

    Func Example()
        ; Retrieve the following text file. This can be found in the include folder which is in the installation path of AutoIt.
        Local $sWow64 = ""
        If @AutoItX64 Then $sWow64 = "\Wow6432Node"
        Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\include\_ReadMe_.txt"

        ; Execute the readme file (.txt) with the default editor used for text files in Windows.
        Local $iPID = ShellExecute($sFile)

        MsgBox($MB_SYSTEMMODAL, "", "PID: " & $iPID)
    EndFunc   ;==>Example