info.mailtraq.com > Management > Script Functions A-Z > ShellExecute() ShellExecute()This function is very similar to ExecuteAsync(), in that it is used to run a program without waiting for it to terminate. However, this command concentrates on files (or documents), rather than the applications used with them. Essentially, the given parameters are passed to the Windows Shell to be handled rather than by calling the application directly. This also makes it possible for the Shell to select an appropriate program to run for a given filename. For example, given the filename of a text document, the Shell may open it using Notepad or WordPad . Specific programs may also be run using this function but you do not need to know their filenames (providing the Shell can locate them).
ShellExecute( filename [ [ [ , parameters ] , command ] , directory ] )
- filename
- The filename of the document to be opened, or the application to be executed. If the filename is an application in the Windows Path a full path-name is not required
- parameters
- Optional parameters given to the application eventually called by the Shell
- command
- Optional; "open" or "print", defaulting to "open"
- directory
- Optional; a string specifying the working directory. Defaults to the database folder.
This example is similar to that shown in ExecuteAsync(). The advantage being that it is not necessary to know the location of the text editor or even which text editor is registered. Note that the Shell selects an application based upon the file's extension (".txt" in this example). To edit a text file which ends with a different extension it is necessary to specify the application as shown in the example expression supplied with the ExecuteAsync() function. // Open the specified file using the default system text editor.
ShellExecute("c:\temp\info.txt")
Note
Use ShellExecute to run DOS batch files. |