Run Flow From Command Prompt or Windows Task Scheduler

A simple way to run flows from Command Line, Windows Task Scheduler, shortcut keys or by using a URL.
How It Works

Run your flow from Command Line (with or without parameters), Windows Task Scheduler, shortcut keys or by using a URL.

The purpose is to create a flow with an endless loop. Insert LABEL Restart at the top (before WAIT). Insert GOTO Restart as the last action in your flow, where the flow ends.

You need to keep the flow constantly running, that’s the drawback. If you don’t wish to do this, then see example Run Through an External Link. That is a Premium feature and requires a license.

Run From Command Prompt
  1. Copy and paste the flow Use Command Prompt or Windows Task Scheduler to your PAD, then run the flow.
  2. Open Command Prompt and type ping localhost -n 1 > NUL
  3. Flow runs and restarts.
Run From Windows Task Scheduler
  1. Copy and paste the flow Use Command Prompt or Windows Task Scheduler to your PAD, then run the flow.
  2. Create a new Action with Program ping and Add arguments localhost -n 1 > NUL
  3. Schedule task or run manually.
  4. Flow runs and restarts.
Run With Shortcut Keys
  1. Copy and paste the flow Use Shortcut Keys to your PAD, then run the flow.
  2. Press either Ctrl+Shift+A (run flow 1) or Ctrl+Shift+B (run flow 2).
  3. Flow runs and restarts.
Run Through an External Link (Premium 👑)

This is a Premium feature, it will require a per user plan license. With this feature, a flow can be run from Command Prompt and Windows Task Scheduler by using a URL. The flow does not need to be started beforehand. If you don’t have a license, then the flow will not simply run at all.

  • Copy and paste the flow Use External Link to your PAD. Do not run the flow.

  • Run from Command Prompt

    • Open Command Prompt and type either:
      "C:\Program Files (x86)\Power Automate Desktop\PAD.Console.Host.exe" "ms-powerautomate:/console/flow/run?workflowName=[Name]"
      or
      "C:\Program Files (x86)\Power Automate Desktop\PAD.Console.Host.exe" "ms-powerautomate:/console/flow/run?workflowId=[workflowId]"
      or
      "C:\Program Files (x86)\Power Automate Desktop\PAD.Console.Host.exe" "ms-powerautomate:/console/flow/run?environmentId=[envID]&workflowName=[Name]"
      or
      "C:\Program Files (x86)\Power Automate Desktop\PAD.Console.Host.exe" "ms-powerautomate:/console/flow/run?environmentId=[environmentId]&workflowName=[workflowIName]"
    • Flow starts.
  • Run from Windows Task Scheduler

    • Create a new Action with Program "C:\Program Files (x86)\Power Automate Desktop\PAD.Console.Host.exe" and Add arguments "ms-powerautomate:/console/flow/run?workflowName=[Name]" (or use any of those other formats, see above)
    • Schedule task or run manually.
    • Flow starts.
Run With Parameters

It’s not possible to add parameters to a PING command and pass those to a PAD flow. Therefore, we will create a new Windows console application (EXE) and it will start the flow, this way we can pass parameters to our flows. The console application will save the parameter to a file and the file is read in PAD.

  1. Download RunPADFlow.exe. This console application have been developed just for this purpose. You can also compile the assembly by yourself (see C# Source Code).
  2. Run RunPADFlow.exe it will create a new file (RunPADFlow.config to current directory) and immediately exit.
  3. Copy and paste the flow Run With Parameters to your PAD. On flow line 4, select the file RunPADFlow.config that was created in previous step.
  4. Open Command Prompt and type RunPADFlow.exe "This is my parameter"
  5. Flow runs and restarts.
C# Source Code

You could also compile the executable by yourself.

Console application .NET Framework 6.0:


using System.IO;
using System.Text;
using System.Threading;

namespace RunPADFlow;

class Program
{
    static void Main(string[] args)
    {
        // Get current file path
        string path = Directory.GetCurrentDirectory();
        string fileName = Path.Combine(path, "RunPADFlow.config");
        string args0 = args.Length > 0 ? args[0] : "";

        // Save argument to file
        using (FileStream fs = File.Create(fileName))
        {
            byte[] info = new UTF8Encoding(true).GetBytes(args0);
            fs.Write(info, 0, info.Length);
        }

        // Without the sleep, the execution is too fast for PAD and the "Wait for process" action will occasitionally fail to start.
        Thread.Sleep(10);
    }
}

Notes

If your flow does not run, check your firewall and/or antivirus settings to ensure that those are not blocking any ping requests.

See Also

Schedule flows using Power Automate for Desktop

PAG Admin
Also See These Flows