LaunchProgram()

Summary

Starts a Windows program.

Changes

In Version 2016 added the Display option.

In Version 2021 added Input and Output options.

Syntax

LaunchProgram(string command_line, opt array options)

Argument Contents
command_line The command line used to run the Windows program; the same string you would type into the Windows Program Manager File/Run dialog
Option Type Contents
Display String How to display the application window: "Hidden", "Normal", "Minimized", or "Maximized"
Input String Filename from which Standard Input is redirected
Output String Filename to which Standard Output is redirected
Error String Filename to which Standard Error is redirected

Notes

  • The options array is an optional argument.

  • The launched Windows program runs normally, as though it is run directly from the Program Manager using the option you choose.

  • See RunProgram() for a description of the search algorithm used if no path is specified for the executable file for the Windows program.

  • LaunchProgram() does not wait for the program to end. Use RunProgram() if you need to halt the GISDK execution while the program runs.

  • If an error occurs, GetLastError() will list the Windows error code. The Error option can be used to redirect error messages.

  • If the Display option is not specified, LaunchProgram() uses the "Normal" option by default.

Example

command = "notepad myfile.txt "
opts = {{"Display", "Maximized"}}
on error do
ResetCursor()
ShowMessage(GetLastError())
Return()
end
SetCursor("HourGlass")
LaunchProgram (command, opts)
ResetCursor()
on error default

Error Codes

Error Type Meaning
Error LaunchProgram() could not locate the program, or otherwise failed to launch it

See Also

Function Summary
RunProgram() Runs a DOS executable program
LaunchDocument() Open a document, executable, or URL with the appropriate program
CallDllFunction() Calls a function in a Dynamic Link Library (DLL)