utils.shellexecute |
---|
Summary Executes a Windows "shell" command Prototype
Description Only the first argument (filename) is required, the rest are optional. filename: The file to open or print or the folder to open or explore. The function can open an executable file or a document file. The function can print a document file. params: A string that specifies the parameters to be passed to the application. If filename specifies a document file, params should be nil or "". defdir: A string that specifies the default directory. operation: The following operation strings are valid: "open": The function opens the file specified by the filename parameter. The file can be an executable file or a document file. It can also be a folder. "print": The function prints the file specified by filename. The file should be a document file. If the file is an executable file, the function opens the file, as if "open" had been specified. "explore": The function explores the folder specified by filename. This parameter can be nil or "". In that case, the function opens the file specified by filename. show_command: If filename specifies an executable file, show_command specifies how the application is to be shown when it is opened. This parameter can be nil in which case it defaults to 1 - the recommended default. This parameter can be one of the following values: 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. 10: Sets the show state based on the SW_ flag specified in the STARTUPINFO structure passed to theCreateProcess function by the program that started the application. An application should call ShowWindow with this flag to set the initial show state of its main window. If sucessful, the function returns true. If not, it returns nil followed by an error message. You could use "assert" to test for failure. Examples:
Warning: If you plan to redirect output (eg. capture a directory listing to a file) you may need to invoke the "cmd" shell. For example:
You may also want to pass 0 as the fifth argument (hide the window) in order to stop a command window flickering into view and then disappearing, for example:
See Also ... Lua functions
utils.activatenotepad - Actvitates the specified notepad window
Topics
Lua base functions
(Help topic: lua=utils.shellexecute) |
Enter a search string to find matching documentation.
Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.