web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Run C# code in Power a...
Power Automate
Suggested Answer

Run C# code in Power automate desktop

(0) ShareShare
ReportReport
Posted on by 17
Hi
 
Is there a way to run C# code in power automate desktop. If any, Please help me with this
 
Thank you
I have the same question (0)
  • Suggested answer
    eetuRobo Profile Picture
    4,495 Super User 2026 Season 1 on at
    Yes you can use "Run .NET Script" -action which has C# language option



    Give it input and output variables with Script parameters Edit and put the code into the .NET code to run.

    Example for reference:


    Script parameters In direction is variable that you want to give from PAD and output variable is what variable the flow produces.

    Good instructions: https://www.samurai-emblem.com/2023/08/02/power-automate-desktop-action-run-dotnet-script/
    Documentation: https://learn.microsoft.com/en-us/power-automate/desktop-flows/actions-reference/scripting
  • Suggested answer
    harish_sada Profile Picture
    53 on at
    Hi @Riyas,
     
     
    follow below steps.
     
     
     
     
     
     
     
     
  • Suggested answer
    Riyaz_riz11 Profile Picture
    4,048 Super User 2026 Season 1 on at
    Hi,
     
    Power Automate Desktop (PAD) does not natively support running C# code directly, but there are workarounds to execute C# logic using external scripts or compiled binaries.
    Here are several practical ways to run C# code within Power Automate Desktop:
    Method 1: Compile C# Code to EXE and Run It
    You can write your C# code in Visual Studio or .NET CLI, compile it to an .exe file, and then use PAD to execute it.
    Steps:
    Create your C# console app:
    In Visual Studio or using the CLI:

    dotnet new console -n MyCSharpApp
    cd MyCSharpApp
    Write your logic in Program.cs:
    csharp

    using System;
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello from C#!");
            // Your logic here
        }
    }
    Build the application:

    dotnet build -c Release
    Locate the .exe file (usually in bin\Release\netX.X\) and copy it to a known location.
    In Power Automate Desktop:
    Use the "Run a program" action.
    Set the path to your .exe.
    Method 2: Use PowerShell to Run Inline C# Code
    PowerShell can compile and run C# code dynamically. PAD supports PowerShell scripting.
    Example PowerShell Script (in PAD):
    powershell

    Add-Type -TypeDefinition @"
    using System;
    public class HelloWorld {
        public string SayHello() {
            return "Hello from C#!";
        }
    }
    "@
    $instance = New-Object HelloWorld
    $instance.SayHello()
    Use the "Run PowerShell script" action in PAD.
    Capture output if needed.
    Method 3: Use .NET Scripting with External Tool Integration
    If you want more flexibility without compiling .exe files every time, you can:
    Use a script host like ScriptCS (C# scripting).
    Or run .csx files with .NET SDK.
    Then invoke them from PAD using the "Run a program" or "Run PowerShell" actions.
    Method 4: Use Power Automate (Cloud) + Azure Functions (C#)
    If you're open to cloud-based execution:
    Write C# logic in Azure Functions.
    Trigger them from PAD using HTTP actions (via REST API).



    If I have answered your question, please mark it as the preferred solution ✅ . If you like my response, please give it a Thumbs Up 👍.
    Regards,
    Riyaz

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 639

#2
Valantis Profile Picture

Valantis 392

#3
11manish Profile Picture

11manish 350

Last 30 days Overall leaderboard