Command-line

The Command-line block is used to execute commands. It can also be used to get dynamic data as input to a case and to integrate with external systems if needed. For example, you can run a PowerShell script or a batch file using the Command-line block.

See the Command-line tutorial to see examples of how to use the command-line block in test cases.

Fully expanded, the Command-line block looks like this:

The Block Header (“Command-line”)

The green input connector in the header is used to trigger the block to start executing.

The green output connector in the header triggers when the command has been executed and the result is ready.

The title of the block (“Command-line”) can be changed by double-clicking on it and typing in a new title.

Command

The command you would like to execute. LEAPWORK can execute all the commands you can run from your Command Prompt.

Text fields(Command)

Add any number of fields that can contain dynamic content and be used as tokens in the command.

Working folder

The ‘working folder’ sets the base directory for running the command. This means that using fully qualified file paths in the command field is not required, as it will be relative to the working directory path.

Text fields(Working folder)

Add any number of fields that can contain dynamic content and be used as tokens in the working folder.

Run as

The user under which you would like to run the command.

Password

The password for the user account.

Method “Get as Text”

Method “Get as Text” will return one text result.

Text result

The complete text result of the command-line execution.

Return code

The default value when an error occurs is 1 and if everything goes well it’s a 0.

Error Occurred

If the command returns an error during execution you can use this output connector to branch your flow.

Method “Iterate”

Method “Iterate” means that you will get every output as an individual string. For each string returned the output connector at the top of the command block is triggered.

Current Line

The current line – the result string that is being iterated.

Current Index

The index of the result string being iterated.

Completed

Once all strings are iterated, the “Completed” output connector is triggered and the workflow can continue from here.

Return Code

The default value when an error occurs is 1 and if everything goes well it’s a 0.

Error occurred

If the command returns an error during execution you can use this output connector to branch your flow.

Timeout (sec)

The maximum time spent waiting for the command to complete before giving up and triggering the green output connector (see above).

If the 'Default Timeout' property checkbox is not selected, then the timeout value is 10 seconds. If the 'Default Timeout' property checkbox is selected, then the 'Default timeout' value selected in the flow settings will be applicable.