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

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

Create a new desktop flow in Power Automate

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

    New flow button.

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

    build flow dialog box.

  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.

    console flow.

Design a flow in Power Automate

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

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

    My flows instant blank.

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

    manually trigger flow.

  4. Select + New step.

    new step.

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

    action search.

  6. In the action, under Run mode select Attended - Runs when you're signed in and under Desktop flow select Create a new desktop flow.

    run Windows recorder (V1) flow properties.

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

    Dialog box.

  8. A message from the browser may appear, asking whether to allow flow.microsoft.com to open an application. Allow this action to continue to Power Automate for desktop.

    browser open application.

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

    add new input variable.

  10. Configure the variable as follows:

    • Variable type: Input
    • Variable name: CountryName
    • Data type: Text
    • Default value: France
    • External name: CountryName
    • Description: This is the country name input variable.

    edit variable input.

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

    get current date and time action properties.

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

    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.

    convert datetime text.

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

    get special folder action properties.

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

    create folder action properties.

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

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

    write text file action properties.

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

    get files folder action properties.

  18. In the Variables pane, create two Output variables as follows:

    • Variable type: Output
    • Variable name: FileCount
    • External name: FileCount
    • Description: This is the file count output variable.

    and

    • Variable type: Output
    • Variable name: FilePath
    • External name: FilePath
    • Description: This is the file path output variable.

    new output variable.

    new output variable 2.

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

    set variable action properties.

    set variable action properties 2.

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

    save complete flow.

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

    pad portal dialog box keep working.

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

    run desktop flow action properties 2.

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

    save test flow.

  24. Select I'll perform the trigger action. and Test.

    test flow.

  25. When Power Automate connects to the desktop app, select Continue, then Run Flow and then Done.

    run flow pop out 3.

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

    successful flow run.

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

    variables values.

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