Pass inputs to a Win Automation Process from Power Automate
In this #PowerShot, I will show you how to pass inputs from a Power Automate flow to a Win Automation Process. Currently, a Win Automation process can be called from a UI Flow in Power Automate and the action allows you to pass command line arguments.
Let's Get Started!
RPA and advanced automation processes built with the Win Automation tool can now be called as actions in UI Flows in Power Automate. In this post, we will look at how to pass inputs to a Win Automation Process from the outputs of a previous action from a flow in Power Automate.
Win Automation Process
Step 1: Search for Win Automation Actions from Actions, drag and drop the Get Command Line Arguments action to the process (if you have already created the process, drag and drop this action to the top of the process). This action gets all the arguments in the form of a list. Note that the default delimiter for command line arguments is <space> key.
Step 2: Search for Variable Actions from Actions, drag and drop the Set Variable action to the process under the Get Command Line Arguments action. In the action inputs, provide %CommandLineArguments% ("CommandLineArguments" is the name of the list that stored all the passed arguments separated by <space> and 0 is the index of the argument that needs to be populated to the variable). Provide a name for the variable (%Name%) in this example.
Step 3: (For multiple inputs, assign those many number of variables) Search for Variable Actions from Actions, drag and drop the Set Variable action to the process under the Get Command Line Arguments action. In the action inputs, provide %CommandLineArguments% ("CommandLineArguments" is the name of the list that stored all the passed arguments separated by <space> and 1 is the index of the argument that needs to be populated to the variable). Provide a name for the variable (%ID%) in this example.
Step 4: In the current example, we just want to display the arguments that have been passed in a message box. Search for Message Boxes action from actions, drag and drop the Display Message action to the main process. In the title pass: Hello %Name% (this will display the text Hello and the first argument from the command line arguments). In the message to display, enter: The ID you have entered is: %ID% (this will display the pre-text along with the second argument passed in the command line arguments). Save the process.
We will first create a UI Flow to invoke the Win Automation process and then call the UI Flow in a main flow.
Step 1: Create a new UI Flow and select the type. (Desktop app in this example)
Step 2: Provide inputs in the first step and then add the Run Win Automation Process action in the steps. Provide the path of the process and then in the Command line arguments, pass the inputs enclosed in "" separated by a <space> key.
Save and test the UI Flow to check if the process is being appropriately called and the sample inputs provided are working as expected.
Step 1: Trigger - Manual Input: Select the manual trigger to trigger the flow and configure the trigger to provide two inputs as shown in the screenshot.
Step 2: Add an action to run the UI flow for Desktop and select the UI flow created in the previous step. Map the input parameters of the action with the ones from the input. Save and test the flow.
Setup in Action
In this post, we saw how to pass inputs to a Win Automation Process via command line arguments from a flow in Power Automate. This is helpful when a process in Win Automation is being called as an action in Power Automate and the process expects or depends on inputs to be passed from previous actions.
I hope you found this interesting and it helped you. Thank you for reading!