functions
fhShellExecute
Description
Executes a Windows "shell" command. Is most commonly used to run an executable file, or to open a document
file using its default application.
Syntax
bOK, iErrorCode, strErrorText = fhShellExecute(strFileName [, strParams [, strDirectory [, strOperation [, iShowCmd]]]])
Parameters
- strFileName
- string: the full path to the file. Remember that slashes in Lua must be doubled (e.g "C:\\My
Documents\\My Program.exe").
- strParams
- string: parameters. If strFileName is an executable file, strParams holds the parameters to be passed to it. Should be empty, or not supplied, if strFileName is a document file.
- strDirectory
- string: specifies the default (working) directory for the action. If not supplied, the current working directory is used.
- strOperation
- string: specifies the action to be performed. The set of available actions depends on the particular
file or folder. Generally, the actions available from an object's shortcut menu are available actions. The
follow actions are commonly used:
edit Launches an editor and opens the document for editing. Will fail if strFileName is not a document file. explore Explores a folder specified by strFileName.
find Initiates a search beginning in the directory specified by strDirectory open
Opens the item specified by strFileName. In this case, strFileName can be a file or folder.
print
Prints the file specified by strFileName. Will fail if strFileName is not a document file. NULL (or empty string)
The default action is used, if available. If not, the "open" action is used. If neither action is available, the system uses the first action listed in the registry.
- iShowCmd
- integer: Specifies how an application is to be displayed when it is opened. If not supplied, the
value defaults to 1. The following values are defined:
0 Hides the window and activates another window 1 Activates and displays a window. If the window is minimized or maximized, Windows restores it to its original size and position. An application should specify this flag when displaying the window for the first time. 2 Activates the window and displays it as a minimized window.
3 Activates the window and displays it as a maximized window.
4 Displays a window in its most recent size and position. The active window remains active.
5 Activates the window and displays it in its current size and position.
6 Minimizes the specified window and activates the next top-level window in the Z order. 7 Displays the window as a minimized window. The active window remains active.
8 Displays the window in its current state. The active window remains active.
9 Activates and displays the window. If the window is minimized or maximized, Windows restores it to its original size and position. An application should specify this flag when restoring a minimized window.
Return ValueS
- bOK
- boolean: rets true on success and false on failure
- iErrorCode
- integer: will be nil if the call succeeded. If it fails will return an error code between 0 and
32, some of the more common ones are listed below.
Return Code MS Name Description 2 ERROR_FILE_NOT_FOUND The specified file was not found.
3 ERROR_PATH_NOT_FOUND The specified path was not found.
11 ERROR_BAD_FORMAT The .exe file is invalid (non-Win32 .exe or error in .exe image).
5 SE_ERR_ACCESSDENIED The operating system denied access to the specified file.
27 SE_ERR_ASSOCINCOMPLETE The file name association is incomplete or invalid.
32 SE_ERR_DLLNOTFOUND The specified DLL was not found.
31 SE_ERR_NOASSOC There is no application associated with the given file name extension. This error will also be returned if you attempt to print a file that is not printable.
8 SE_ERR_OOM There was not enough memory to complete the operation.
26 SE_ERR_SHARE A sharing violation occurred.
- strErrorText
- string: will be nil if the call succeeded. If it fails, will contain a textual description of the error. May be less specific than the iErrorCode. For some unusual error codes strErrorText may just contain the text "An error has occurred".