Create a Power Automate desktop flow
Desktop flows are used to automate tasks on the Web or the desktop. Using Power Automate you can automate tasks on the desktop as well as the Web. Alternatively, you can use the two legacy methods of creating desktop flows: Windows recorder (V1) and Selenium ID.
Prerequisites
Important
Gateways for desktop flows are now deprecated except for China region. Switch to our machine-management capabilities. Learn more
To trigger desktop flows through Power Automate, you have to use machines or machine groups. Machines are physical or virtual devices that are used to automate desktop processes. Machine groups allow you to organize multiple machines together to help distribute your automation workload.
As an alternative to the machines, you can use the on-premises data gateway. The gateway is an enterprise-grade secure connection between Power Automate and your device.
To create a desktop flow in Power Automate, you need a Microsoft work, school or organization premium account. To create and trigger a desktop flow through Power Automate, you need an organization premium or trial premium account.
Important
You must use the same work or school account to set up the gateway, to sign into Power Automate, and to log into your Windows device.
Start creating desktop flows using examples
Power Automate provides an extensive collection of examples to introduce users to RPA. You can find all the available examples under the Examples tab in the console.
To copy an example to your flows, right-click on it and select Create a copy. The copied flow will be stored under the My flows tab.
If you've opened and edited an example in the flow designer, select the Save as button to copy the edited example to your flows. The changes can't be saved to the original example flow.
Create a new desktop flow in Power Automate
To create a desktop flow in Power Automate, open the app and select New Flow.
Enter a name for the desktop flow, and select OK.
Create the flow in the flow designer and press Ctrl+S to save the flow. Close the flow designer and the flow will appear in the console.
Design a flow in Power Automate
Create a new folder on the desktop, and name it Countries.
Go to make.microsoft.com, select My flows, then +New flow, and Instant cloud flow.
In the dialog box, enter a cloud flow name, select Manually trigger a flow, and then select Create.
Select + New step.
Search for Power Automate, and select the Run a flow built with Power Automate for desktop action.
If there isn't an existing connection to your machine, the action prompts you to create one. You can find more information regarding triggering flows on machines in Manage machines.
In the action, under Run mode, select Attended (runs when you're signed in) and then under Desktop flow, select Create a new desktop flow.
Enter a desktop flow name or one will be generated and then select Launch app.
A message from the browser may appear, asking whether to allow make.microsoft.com to open an application. Allow this action to continue to Power Automate for desktop.
In Power Automate for desktop, open the Variables pane, select + and select Input to add a new input variable.
Configure the variable as follows:
- Variable name: CountryName
- Data type: Text
- Default value: France
- External name: CountryName
- Description: This is the country name input variable.
Add the Get current date and time action and set Retrieve to Current date only. Select Save to add the action to the workspace. This action retrieves only the current date, and stores it in a variable.
Add the Convert datetime to text action. In Datetime to convert, select the variables icon and double-click on %CurrentDateTime% in the pop-out to add the variable to the field.
For Format to use set Custom, and enter MM-dd-yyyy in Custom Format. This action converts the datetime variable to a text variable, while also converting the date to the specified format.
Add the Get special folder action. The Special folder name will default to Desktop. This action stores the location of the current user's Desktop in a variable.
Add the Create folder action and set Create new folder into to %SpecialFolderPath%\Countries and New folder name to %CountryName%. This action creates a new folder with the specified name, in the specified location.
Add the Write text to file action and use the variables pop-out to set File path to %SpecialFolderPath%\Countries\%CountryName%\%FormattedDateTime%.txt.
Note
To use both hardcoded text and variables in the field, populate the hardcoded text manually, and use the variables pop-out to insert each variable in the currently selected part of the text.
Set Text to write to This text was written by Power Automate. This action writes the specified text to a text file on the current user's desktop, and sets the filename to the current date.
This action writes the specified text into a text file.
Add the Get files in folder action and set Folder to %SpecialFolderPath%\Countries\%CountryName%. This action retrieves a list of the files in a specified folder.
In the Variables pane, create two Output variables as follows:
- Variable name: FileCount
- Data type: Number
- External name: FileCount
- Description: This is the file count output variable.
and
- Variable name: FilePath
- Data type: Text
- External name: FilePath
- Description: This is the file path output variable.
Add two Set variable actions and configure them as follows:
- Set variable: FilePath
- To: %SpecialFolderPath%\Countries\%CountryName%\%FormattedDateTime%.txt
and
- Set variable: FileCount
- To: %Files.count%
Select Save to save the flow and close the flow designer.
Back in Power Automate, in the dialog box select Keep Working.
Select the new desktop flow in the action, and enter Greece into CountryName.
Select Save to save the flow and then select Test.
Select Manually and Test.
When Power Automate connects to the desktop app, select Run flow, and then Done.
When the flow finishes running, all actions will have a green checkmark icon and a notification will confirm that the flow ran successfully.
Select the Run a flow built with Power Automate for desktop action to open its inputs and outputs. The values of the two variables, FileCount and FilePath, were returned from Power Automate. Similarly, any output variables may be used elsewhere in the flow.
Check the Countries folder on the desktop. A folder with the name Greece has been added, and contains a text file with today's date.
Feedback
Submit and view feedback for