.net robot launching question

Is it possible to launch a robot process through a WCF service interaction or an API call of some sort? My organisation does not use Orchestrator at all so using the Orchestrator API calls is out of the question here.
I found some old info on the Robot API but that no longer appears to be supported and the package is no longer available on myget.org for it.

You can use the Windows Task Scheduler for launching a robot process.

https://forum.uipath.com/t/how-to-run-uirobot-by-windows-task-scheduler

Hi @alexander.cleak,

You can write a simple bat file with the following contents and save it to your desired location.

“FullPathToYourUIROBOTEXE\UiRobot.exe” execute --file “FullPathToYourProcessXAMLfile\Main.xaml”
The quotes are important as some paths may have spaces which bat files do not allow.

  1. In your Task Scheduler in windows you can create a basic task
    image
    Click ok in the first window after checking on the yellow marker. This ensures that UiRobot.exe has the required access level. In the image the task is for some other automation so ignore the choice I make.
    image

  2. In the triggers window you can set the schedule you want your robot to run.

  3. When you reach the actions window choose to run your batfile in powershell (Here I run a ps.1 script but you can replace it with the full path of your bat file).

Usually powershell.exe is found in this path. Check if this is true in your case: "C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe"

Also ensure that your powershell execution policy is set correctly before setting up the task. Else your task will not run : Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser

Hi Jeevith,

Due to system setup and restrictions, we cannot run batch files, powershell or anything from task scheduler on the virtual machines that the robots run on. It needs to be a call of some sort from within a coded application, in this case built in C#.

Thanks,
Alex

I understand. Sadly my understanding of C# is low so cant help with a robust solution.
But if there is a way in C# for you to invoke a CMD instance then the contents of the bat file will start the robot.

So I would suggest you look for a ways to invoke a cmd command from within a C# program and the command being the following.

“FullPathToYourUIROBOTEXE\UiRobot.exe” execute --file “FullPathToYourProcessXAMLfile\Main.xaml”

Do update this thread when you find a solution. I am interested in what you find. Thank you :slight_smile:

2 Likes

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!