RunProgram Method
Object List Next Object
Defined By: SystemTools
Description:
In its simplest form, you can specify the command to run, whether to wait for
the command to finish, and whether or not the command gets a console which is
detached from the parent process’ console.
Declaration:
Function RunProgram(ByVal cmdLine As String, ByVal wait As Long, ByVal detach
As Long) As Long
Details:
Arguments to the program can be given in the “cmdLine” string, just as they would be typed to a system command prompt. However, note
that you cannot redirect input or output using “<“ or “>“ in the cmdLine string. To redirect command I/O, use one of the other
RunProgram methods and specify the handles for the input, output, and error streams.
The effect of the “detach” flag depends on whether the cmdLine specifies a console program or a GUI
program; experimentation is often the best way to find the appropriate setting for
the desired result. In general, for a console program, if the argument to the
detach parameter is zero, then that program will display a console when it runs.
This is useful for console programs that require interaction from the user. If
a non-zero detach argument is given, then the program is not automatically
given a console, and most common console utilities will complete “silently,” which is often the desired behavior.
The "wait" argument can be specified as:
Setting Description
-1 Wait as long as it takes for the process to terminate
0 Don't wait
all others Timeout period in milliseconds
This method also returns a value interpreted as follows:
-1 - a wait period was given, and the wait period has expired
0 - a wait period was given, and the process has completed
- - no wait period was given, and the program was successfully started