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.

Screenshot of 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.

Screenshot of the Create a copy option of an example.

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.

Screenshot of the Save as button in an open example.

Create a new desktop flow in Power Automate

  1. To create a desktop flow in Power Automate, open the app and select New Flow.

    Screenshot of the New flow button in the console.

  2. Enter a name for the desktop flow, and select OK.

    Screenshot of the Build a flow dialog.

  3. 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.

    Screenshot a desktop flow in the console.

Design a flow in Power Automate

  1. Create a new folder on the desktop, and name it Countries.

  2. Go to make.microsoft.com, select My flows, then +New flow, and Instant cloud flow.

    Screenshot of the Instant cloud flow option in the Power Automate portal.

  3. In the dialog box, enter a cloud flow name, select Manually trigger a flow, and then select Create.

    Screenshot of the Manually trigger a flow option.

  4. Select + New step.

    Screenshot of the New step button.

  5. Search for Power Automate, and select the Run a flow built with Power Automate for desktop action.

    Screenshot of the field to search for actions.

  6. 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.

    Screenshot of the machine connection settings.

  7. 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.

    Screenshot of the properties of the Run a flow built with Power Automate Desktop action.

  8. Enter a desktop flow name or one will be generated and then select Launch app.

    Screenshot of flow name field in the Build a desktop flow dialog.

  9. 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.

    Screenshot of a browser message asking whether to allow to open an application.

  10. In Power Automate for desktop, open the Variables pane, select + and select Input to add a new input variable.

    Screenshot of the button to add a new input variable.

  11. 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.

    Screenshot of the Add a new input variable dialog.

  12. 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.

    Screenshot of the Get current date and time action.

  13. 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.

    Screenshot of the icon to select variables in the Convert datetime to text action.

    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.

    Screenshot of the populated Convert datetime text action.

  14. 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.

    Screenshot of the Get special folder action.

  15. 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.

    Screenshot of the Create folder action.

  16. 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.

  17. 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.

    Screenshot of the Write text file action.

  18. 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.

    Screenshot of the Get files folder action.

  19. 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.

    Screenshot of the dialog to create the FileCount output variable.

    Screenshot of the dialog to create the FilePath output variable.

  20. 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%

    Screenshot of the Set variable action that creates the FilePath variable.

    Screenshot of the Set variable action that creates the FileCount variable.

  21. Select Save to save the flow and close the flow designer.

    Screenshot of the Save button in the flow designer.

  22. Back in Power Automate, in the dialog box select Keep Working.

    Screenshot of the Keep working option in the Power Automate dialog box.

  23. Select the new desktop flow in the action, and enter Greece into CountryName.

    Screenshot of the input variables in the Run a flow built with Power Automate Desktop action.

  24. Select Save to save the flow and then select Test.

    Screenshot of the Save and Test options.

  25. Select Manually and Test.

    Screenshot of the option to perform the trigger action.

  26. When Power Automate connects to the desktop app, select Run flow, and then Done.

    Screenshot of a dialog showing that the flow ran successfully.

  27. When the flow finishes running, all actions will have a green checkmark icon and a notification will confirm that the flow ran successfully.

    Screenshot of a message showing that the flow ran successfully.

  28. 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.

    Screenshot of the values of the input and output variables.

  29. 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.