Run attended and unattended desktop flows

After you've created and tested a desktop flow, you can run it from an event, schedule, or button. To make this possible, add your desktop flow to an automated flow, a instant flow, a scheduled flow, or a business process flow.

Prerequisites

  • You need the on-premises data gateway for your device to have the desktop flow triggered by Power Automate.

    The gateway is an enterprise-grade secure connection between Power Automate and your device (where your desktop flows run). Power Automate uses the gateway to access your on-premises device so that it can trigger your desktop flows from an event, schedule, or button.

  • You need to setup a desktop flow connection

  • A work or school 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.

Run desktop flows unattended or attended

When you create desktop flows, you run them either in attended or unattended mode. Unattended is best for applications that do not need human supervision.

When running unattended, Power Automate automatically signs into the target devices that run Windows 10, Windows Server 2016, or Windows Server 2019. Once the automation completes, Power Automate signs out from the device and reports its activity.

When running attended, Power Automate uses an existing Windows user session.

When you add a desktop flow to a cloud flow, you can choose whether you want your dekstop flow to run attended or unattended. Here are some key differences between attended and unattended runs:

Unattended mode

To run unattended desktop flows, the target machine needs to be available with all users signed out.

Important

Locked Windows user sessions will prevent desktop flows from running.

Power Automate performs the following:

  1. Power Automate creates, manages, and then releases the Windows user session on the target devices.

  2. Unattended desktop flows run on devices with the screen locked so that no one can see the flow while it runs.

  3. Windows 10 devices cannot run unattended if there are any active Windows user sessions present (even a locked one). You will receive this error: Cannot execute desktop flow. There is a locked or an inactive Windows user session on the target device.

  4. On Windows Server, if you have a locked Windows user session open with the same user as the desktop flow is supposed to run as, you will receive the same error: Cannot execute desktop flow. There is a locked or inactive Windows user session on the target device.

Attended mode

To run an attended desktop flow, you need to have an active Windows user session that matches the name of the user configured for your connection. The session must not be locked.

When an attended desktop flow starts on the target machine, we recommend that you avoid interacting with your device until the run completes.

Run multiple desktop flows on the same device sequentially

You can schedule multiple desktop flows to run on one or more devices. If more than one desktop flow is triggered to run on the same device, Power Automate follows these rules:

  1. The first desktop flow runs on the target device.

  2. Queues other desktop flows and then displays them as Waiting in the desktop flows and gateway details page.

  3. Picks the next Waiting desktop flow when each run completes.

Note

These orchestration rules apply to desktop flows runs that are scheduled by any user on the same device.

Important

If there are too many desktop flows in the execution queue a timeout might occur. Desktop flows runs will fail if they don’t run within 30 minutes after being triggered.

Run desktop flows concurrently on Windows Server devices

Multiple users can be signed in simultaneously on Windows Server 2016 and Windows Server 2019. Power Automate leverages this OS capability to simultaneously run multiple desktop flows on such devices. With this feature, your organization can save on its infrastructure costs.

Perform the following steps to benefit from multiple desktop flows on a single device:

  1. Setup a Windows Server 2016 or 2019 device with the on-premises gateway and the latest version of desktop flows installed.
  2. Use two or more user accounts to create desktop flows connections targeting the gateway on this device.

Power Automate automatically scales the number of concurrent desktop flows runs to the maximum supported by the device. If the capacity of the device is exceeded, the additional runs wait as described here.

Important

If you want to use more than two parallel user sessions on Windows Server, you must turn on Remote Desktop Services. Learn more about RDS.

Note

Running multiple concurrent desktop flows by the same user is not supported. You will need to have different users running desktop flows at the same time to benefit from this feature.

Load balance requests across gateways in a cluster

You can choose to distribute desktop flows runs evenly across gateways in a cluster. By default, the selection of a gateway during load balancing is random.

Follow these steps to add a gateway to create a cluster

Note

Offline gateway members within a cluster will negatively impact performance. Disable or remove these members.

To provide load balancing from the Power Automate gateway details page, navigate to Data -> Gateways, and then select your gateway cluster.

In the gateway details page, toggle Run on all gateways in cluster. This will distribute the desktop flows runs on all the gateways within that cluster.

Distribute desktop flow run on gateway cluster

Important

If you are using local Windows accounts, all machines in the cluster must have the same local account with the same password. Use these credentials when you create the desktop flows connection. If you are using Active Directory or Azure AD joined machines, confirm that the user account you will be use in the desktop flows connection can access all machines in the cluster.

Best practices to avoid timeouts and distribute load across machines

If you plan to run multiple desktop flows, there are a set of strategies you can adopt to distribute load and ensure that all your desktop flows run successfully without overloading the target machine(s) or running into timeouts because multiple desktop flows are running at the same time. You can either:

  1. Plan your desktop flows to run at different times of the day, spreading your load over time. This works best if you have a single or a limited set of machines that can run workloads, and you can control the triggers (for example, scheduled flows) that start your desktop flows.
  2. Create clusters of machines that can run desktop flows with identical configurations in parallel.
  3. Create multiple flows that each use a separate connection to target different machines.

By following these strategies, you can avoid having desktop flows competing to run on the same device and in some cases failing due to timeouts.

Note

If you are running desktop flows in unattended mode, you will need to anticipate the number of desktop flows your organization plans to run in parallel, and then purchase an adequate amount of Unattended Add-ons.

Rerun failed desktop flows

If a desktop flow run fails, correct the issue, and then try the following steps to rerun it:

  1. Go to the details page and identify the failed run.

  2. Select the Resubmit button from the action menu.

Troubleshoot failures

  1. If your unattended desktop flow fails with the cannot create new session message, follow these steps to resolve the issue:

    • On Windows 10, confirm that you don’t have an active user session locked or unlocked on your target device.
    • On Windows Server 2016 or Windows Server 2019, confirm you haven’t reached the maximum number of active user sessions that's configured for your device. Desktop flows won’t be able to run if it cannot create new sessions.
  2. If the gateway status is offline, confirm that the device is turned on and connected to the Internet. You may also troubleshoot the gateway.

  3. If the gateway status is online, try the following actions:

    • Confirm the desktop flows app and services are running on your device.

    • Restart the service on your device.

Learn more

Runtime notifications

A notification popup appears by default when a desktop flow is downloading or running, when it is cancelled, when it finishes running successfully, or when it encounters an error:

Notification window

Note

Can you tell us about your documentation language preferences? Take a short survey.

The survey will take about seven minutes. No personal data is collected (privacy statement).