Execute Python Script in Desktop flow using Microsoft Power Automate

Microsoft Power Automate is a software by Microsoft for the automation of recurring tasks. It is part of the Microsoft Power Platform line of products together with products such as Power Apps and Power BI. More Details https://powerautomate.microsoft.com/en-us/

Desktop flows are the existing robotic process automation (RPA) capabilities in Power Automate and enable to automate of all repetitive desktop processes.

Scripting actions enable you to run blocks of code and implement custom behavior in your desktop flows. All scripting actions follow the basic structure of the respective programming or scripting language: PowerShell, Python, DOS Command, VBScript, and JavaScript.

Execute the Python scripts to declare new variables and return values from Run Python script actions, which use the print function.

Reading this article, you can learn how to Execute the Python scripts using Run Python script actions with the Desktop flow in Microsoft Power Automate.

The following important tools are required for developing Microsoft Power Automate,

  1. Windows 10/11 (Recommended)
  2. Power Automate Desktop - Download the Power Automate installer

Now we can discuss step-by-step App development.

Step 1. Open Microsoft Power Automate ->  New Flow

Next, Give the Flow name as PADPython, Click the Create button,

Execute Python Script in Desktop flow

After that, we can see the Desktop flow,                                           

Execute Python Script in Desktop flow

Step 2. For Testing, Run Python script action in Scripting actions,

Add the Run Python script action, and Set the Python script to run parameter as

import re

text="Welcome to C# Corner!............"

print text

Click the Save Button

Execute Python Script in Desktop flow

The following variables are produced automatically; for the script's output PythonScriptOutput variable, we enable the ScriptError variable for errors that may occur during the execution of the Python script code.

Execute Python Script in Desktop flow

For Displaying the Python Script Output, Add the Display message action, Set the Message box title Parameter value as "DispOutput", and Message to display Parameter value as

%PythonScriptOutput%

%ScriptError%

and Click the Save Button

Execute Python Script in Desktop flow

Now, Save the PADPython Desktop Flow,

Execute Python Script in Desktop flow

Step 3. Now we can run your PADPython Desktop Flow in Microsoft Power Automate, 

The output of the PADPython,

Execute Python Script in Desktop flow

Summary

You have successfully tested the Python Script action in Desktop flow – PADPython in Microsoft Power Automate.


Similar Articles