Purpose
Runs an executable program. You can issue this statement from the MapBasic window in MapInfo Pro.
Syntax
Run Program program_spec
program_spec is a command string that specifies the name of the program to run, and may also specify command-line arguments.
Description
If the specified program_spec does not represent a Windows application, MapBasic invokes a DOS shell, and runs the specified DOS program from there. If the program_spec is the character string "COMMAND.COM", MapBasic invokes the DOS shell without any other program. In this case, the user is able to issue DOS commands, and then type Exit to return to MapInfo. When you spawn a program through a Run Program statement, Windows continues to control the computer. While the spawned program is running, Windows may continue to run other background tasks―including your MapBasic program. This multitasking environment could potentially create conflicts. Thus, the MapBasic statements which follow the Run Program statement must not make any assumptions about the status of the spawned program.
When issuing the Run Program statement, you should take precautions to avoid multitasking conflicts. One way to avoid such conflicts is to place the Run Program statement at the end of a sequence of events. For example, you could create a custom menu item which calls a handler sub procedure, and you could make the Run Program statement the final statement in the handler procedure.
Example
The following Run Program statement runs the Windows text editor, "Notepad," and instructs Notepad to open the text file THINGS.2DO.
Run Program "notepad.exe things.2do"
The following statement issues a DOS command.
Run Program "command.com /c dir c:\mapinfo\ > C:\temp\dirlist.txt"
See Also:
Run Application statement, Run Command statement, Run Menu Command statement