Knowledge base
Tips and tricks Best practice guides, FAQ & more
Find tutorials, guides and use case examples in the
Learning center
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 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.
The command you would like to execute. LEAPWORK can execute all the commands you can run from your Command Prompt.
Add any number of fields that can contain dynamic content and be used as tokens in the command.
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.
Add any number of fields that can contain dynamic content and be used as tokens in the working folder.
The user under which you would like to run the command.
The password for the user account.
Method “Get as Text” will return one text result.
The complete text result of the command-line execution.
The default value when an error occurs is 1 and if everything goes well it’s a 0.
If the command returns an error during execution you can use this output connector to branch your flow.
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.
The current line – the result string that is being iterated.
The index of the result string being iterated.
Once all strings are iterated, the “Completed” output connector is triggered and the workflow can continue from here.
The default value when an error occurs is 1 and if everything goes well it’s a 0.
If the command returns an error during execution you can use this output connector to branch your flow.
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.
©2024, Leapwork. All rights reserved.