Wait For Command

   

 

The Wait For Command action allows you to execute an external process and wait until it exhibits certain behaviour, or returns a certain value. For an overview of "Wait For..." events, including specifics of the Wait Options, see the Waiting For Events topic.

 

(Note that because some executables may use a large amount of system resources, you may wish to set the polling interval on the Wait Options to a high value.)

 

 

waitforcommand

 

Executable Command

 

Specify the details of the executable to run. You can specify a starting directory, and any command line arguments you wish to pass to the executable.

 

Note that even if the Wait For action times out, the executable program will not be terminated if it is hung. If a hung process is a likely possibility, it is recommended to use Wait For Process (with timeout) and a WMI Kill Process action in an Async Action Group, alongside the Wait For Command.

 

 

"Wait for exit code..."

 

You can wait for a single exit code value, or a range of exit codes. Normally, a non-zero exit code indicates an error. However, many applications do not return meaningful exit codes. See the documentation for the executable you want to run to find out if it returns exit code values.

 

 

"Wait for output to contain string:"

&

"Wait for output to not contain string:"

 

These two options will search for a substring in the output from the executable and continue if it is found (or not found.) Both StdOut and StdErr are captured.

 

Check the "Match as regular expression" box to match the substring as a regular expression.

 

 

"Expand variables before every execution of command"

 

If this option is set, variable names (ie %VariableName%) in the action parameters will be expanded every time the target command is run. Otherwise, they are only expanded once (when the action starts waiting.)

 

Setting this option allows you to change the parameters of the wait call while it is running. However, it should not be taken lightly. In particular, note that variable changes are not atomic. This means that while one variable value may have been updated, another may not yet have been updated when the executable is run. This can lead to unspecified behaviour. If you really want to change the parameters while running, a safer bet is to choose this option, but change the actual action properties from the OnCommandOutput script event - see below. This guarantees that all the arguments are changed at once.

 

 

Script Events

 

In addition to the normal Wait script events, Wait For Command provides an OnCommandOutput event. This script event allows you to do more advanced parsing of the command output (available in the Output parameter) or the exit code (available in the Exit Code parameter.) Set the Continue parameter to True in order to stop waiting and continue the project run.

 

(Tip: If you wish to depend solely upon the OnCommandOutput event for control of waiting, set the action to wait for an improbable exit code - ie -1.)