Runs an executable and redirects the output to OpenInsight.

Syntax

SRP_Run_Command(Command, Output, WorkingDir, TimeDelay)

Parameters

Title FieldDescription
CommandThe DOS prompt command to execute. Required.
OutputIndicates how the command output is redirected. Optional. Output is not redirected if omitted.
WorkingDirSets the working directory. Optional. Defaults to current working directory if omitted.
TimeDelayTime, in milliseconds, to allow the process to run before checking for more output. Optional. Defaults to 250 if omitted.

Remarks

The SRP_Run_Command is convenient way to execute DOS command lines from OpenInsight, especially when you need to redirect the output to something other than a DOS window. Note that SRP_Run_Command executes these commands synchronously, that is, it will not return until the command completes execution.

The Command parameter is the only required variable. Simply set this to the command you wish to execute. This can be any valid command acceptable to the DOS window.

The Output parameter controls where output is redirected. The output can be redirected to three locations: variables, DOS window, or an OpenInsight EDITLINE or EDITBOX.

To redirect output to a variable, set a variable to the value of "VAR" and pass it via the Output parameter. When SRP_Run_Command returns, the variable you passed will contain the output data. To redirect to a DOS window, set the Output parameter to "DOS" or "DOSOPEN". Use "DOSOPEN" to keep the DOS window open after the process completes. Use "DOS" to close the DOS window automatically. Finally, if you want to redirect the output to an OI EDITLINE or EDITBOX, simply set the Output parameter to the fully qualified control entity id. If you omit the Output parameter, the output will not be redirected.

Some commands ask for user input, so use caution when redirecting output to a variable or OI control since neither of these options can accept user input. In the event that input is requested and the output is set to "VAR" or an OI control, the application will appear to hang while waiting for the process to end. To bring control back to the application, you'll need to kill the process that is waiting for input via the Task Manager.

The WorkingDir parameter sets the working directory for the process. Note that this will not affect the current working directory for OpenInsight. This is useful if you are running a command that relies on the current working directory, such as the "dir" DOS command. If you want to use OpenInsight's current working directory, simply omit this variable or leave it blank.

The TimeDelay parameter determines the frequency in which SRP_Run_Command polls for output. Most DOS commands take time to deliver output, so there is no need to redirect it every CPU cycle. Instead, it's best to check for new output every so often. You can have it wait as long as several seconds or have it check every millisecond. If you leave this parameter blank or omit it, then SRP_Run_Command will check for output every 250 milliseconds.

Examples

* Run a simple command
SRP_Run_Command("ipconfig")

* Run a simple command and redirect output to a variable
Output = "VAR"
SRP_Run_Command("ipconfig", Output)

* Run a simple command and redirect output to a DOS window
SRP_Run_Command("ipconfig", "DOS")

* Run a simple command and redirect output to an EDITBOX
SRP_Run_Command("ipconfig", @Window:".MY_EDITBOX") 

* Run a simple command using a different working directory
SRP_Run_Command("dir", @Window:".MY_EDITBOX", "C:\Windows")

* Run a simple command and slow down the output polling to 1 second
SRP_Run_Command("ipconfig", @Window:".MY_EDITBOX", "", 1000)
  • No labels