.net robot launching question

Hi @alexander.cleak,

I tried this today and the robot can be triggered from a .net program as described below. The main requirement with this approach is that the full path to both the UiRobot.exe and the Process.xaml file need to be mentioned in the .bat file.

Approach:

  1. Make a simple .bat file with the following contents
Echo "Starting the UiRobot.exe and executing a UiPath .xaml example file."

"C:\Users\%username%\AppData\Local\UiPath\app-20.10.2\UiRobot.exe" execute --file "C:\Users\%username%\Documents\UiPath\ForumAnswers\IEnumerableUiElement.xaml"

Echo Execution Ended" 

  1. Make a .net Console App (Project) in Visual studio
    image

  2. Create a program.cs file with the following contents.
    This invokes the CMD.exe to run the .bat file from Step 1.

using System;

namespace ExecuteUiPathRobot
{
    class Program
    {
        static void Main(string[] args)
        {

            // This thread was really helpful https://stackoverflow.com/questions/1469764/run-command-prompt-commands

            // Step 1: First we make a bat file which contains the command 
            // “FullPathToYourUIROBOTEXE\UiRobot.exe” execute --file “FullPathToYourProcessXAMLfile\Main.xaml”

            // Step 2: We use /K to ensure that we can see CMD execution window    
            string userName = Environment.UserName;
            string batfilepath = "/K C:/Users/"+userName+"/Downloads/executeUiPathRobot.bat";

            // Step 3: We invoke the batfile contents using Process.Start method 
            try
            {
                System.Diagnostics.Process.Start("CMD.exe", batfilepath);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
    }
}

  1. You can further integrate this into your C# code as per your use case with better exception handling offcourse :slight_smile:

Trying to solve this was fun. Thanks!