RunProgram()

Summary

Runs a program, and waits for the program to complete before continuing.

Changes

In Version 2016 added the Display option.

In Version 2021 added Input and Output options.

Syntax

status = RunProgram(string command_line, array options)

Argument Contents
command_line The command line, including arguments and/or switches, used to start the program
Option Type Contents
Minimize Boolean If "True" the program is run minimized
Maximize Boolean If "True" the program is run maximized
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

Returns

The exit code of the program if the program runs successfully. Most programs return zero upon successful completion.

The Windows system error code if there is an error launching the program. For example, error code 2 means "Not Found", indicating that either the program or a DLL that the program depends on was not found.

Notes

  • DOS programs are displayed in DOS windows while they are running.

  • If the command line contains only a file name for the executable file, a search is conducted for the program in: the current, Windows, and Windows system directories, and in those directories listed in the PATH environment variable.

  • RunProgram() can be used to execute DOS commands by putting "cmd /c" before the DOS command.

  • RunProgram() can be used to execute DOS batch files.

  • While the program is running, all platform windows (maps, editors, etc.) are hidden.

  • If your GISDK program uses timers, disable them before running a program with RunProgram().

  • You cannot combine the minimize and maximize options; only one can be used at a time.

Example

status = RunProgram("dirlist.bat", )
status = RunProgram("myprog.exe", {{"Maximize", "True"}})
status = RunProgram("notepad myfile.txt",)
status = RunProgram("cmd /c copy d:\\tmp.txt d:\\bar.txt", )

See Also

Function Summary
LaunchProgram() Start a Windows program