How to start UiPath Robot from an IIS site (PHP) built within the same Windows PC?

I’m using UiRobot.exe version 22.4.1.0 .

I want to build a website using IIS (PHP) on the same terminal, and launch a specific RPA package when a button is launched.
The IIS application pool ID matches the UiPath execution environment user, but it cannot be started and the following error appears in Event Viewer.

UiPath.Service.UserHost 22.4.1.0 
UiPathUserServices_TESTDOMAIN@testuser 64000770 IStudioOperations GetFeeds 0. # System.ComponentModel.Win32Exception (5): アクセスが拒否されました。
   at System.Diagnostics.ProcessManager.OpenProcess(Int32 processId, Int32 access, Boolean throwIfExited)
   at System.Diagnostics.Process.GetProcessHandle(Int32 access, Boolean throwIfExited)
   at System.Diagnostics.Process.GetOrOpenProcessHandle()
   at System.Diagnostics.Process.EnsureWatchingForExit()
   at UiPath.Service.UserHost.AttendedServiceProxy.RegisterClientProcess(Int32 clientPid)
   at UiPath.Service.UserHost.StudioOperations.Prepare(ClientProcessMessage message, CancellationToken ct)
   at UiPath.Service.UserHost.StudioOperations.GetFeeds(StudioAgentMessage args)
   at UiPath.CoreIpc.Server.<>c__DisplayClass7_3.<<-ctor>g__InvokeMethod|6>d.MoveNext()
--- End of stack trace from previous location ---
   at UiPath.CoreIpc.Server.<>c__DisplayClass7_1.<<-ctor>g__HandleRequest|3>d.MoveNext()
--- End of stack trace from previous location ---
   at UiPath.CoreIpc.Server.<>c__DisplayClass7_2.<<-ctor>b__5>d.MoveNext()
--- End of stack trace from previous location ---
   at UiPath.CoreIpc.Helpers.Timeout[TResult](TimeSpan timeout, List`1 cancellationTokens, Func`2 func, String message, Func`2 exceptionHandler)

I am trying to start a Robot from PHP using the program below.

exec('"C:\Program Files\UiPath\Studio\UiRobot.exe" execute --file "C:\ProgramData\UiPath\Packages\TEST_ROBOT.1.0.8900.29500.nupkg"', $output);

How can I start a Robot from my local web system?

Thank you.

Hi there,

To start a UiPath Robot from an IIS site (PHP) built on the same Windows PC, you’ll need to ensure proper permissions and configurations. Here are the steps to achieve this:

  1. Ensure Proper Permissions: The IIS application pool user must have the necessary permissions to run UiPath Robot. You can achieve this by setting the application pool identity to a user that has permission to run the robot.

  2. Configure IIS and PHP: Make sure your PHP script can execute external programs and that the path to UiRobot.exe is correct.

  3. Update PHP Script: Modify the PHP script to handle any potential permission issues and ensure it can correctly call the UiPath Robot executable.

  4. Handle Security Policies: Update the security policies on your machine to allow the execution of UiRobot.exe by the IIS application pool user.

Detailed Steps

  1. Set Application Pool Identity

    Set the application pool identity to a user that has permission to run UiPath Robot:

    • Open IIS Manager.
    • Select the Application Pool for your site.
    • Click “Advanced Settings”.
    • Set the “Identity” under “Process Model” to a user with the necessary permissions (e.g., a local admin or the user under which UiPath Robot is configured to run).
  2. Grant Necessary Permissions

    Ensure the user has “Log on as a batch job” rights:

    • Open Local Security Policy (secpol.msc).
    • Navigate to Local PoliciesUser Rights Assignment.
    • Find “Log on as a batch job” and add the application pool user.
  3. Modify PHP Script

    Update your PHP script to handle paths and permissions correctly:

    <?php
    // Define the path to UiRobot.exe
    $uiRobotPath = 'C:\Program Files\UiPath\Studio\UiRobot.exe';
    
    // Define the path to the .nupkg file
    $packagePath = 'C:\ProgramData\UiPath\Packages\TEST_ROBOT.1.0.8900.29500.nupkg';
    
    // Build the command
    $command = "\"$uiRobotPath\" execute --file \"$packagePath\"";
    
    // Execute the command
    exec($command, $output, $return_var);
    
    // Check for success
    if ($return_var === 0) {
        echo "Robot started successfully.";
    } else {
        echo "Failed to start robot. Return code: $return_var";
        print_r($output);
    }
    ?>
    
  4. Adjust Security Policies

    If you encounter access denied errors, you might need to adjust security settings:

    • Make sure the IIS application pool user has the necessary permissions to access the directories and execute UiRobot.exe.
    • Ensure the IIS application pool user can interact with the desktop (you might need to enable “Interact with desktop” for the application pool if needed).
  5. Testing and Debugging

    • Check the Event Viewer for detailed error messages if the robot fails to start.
    • Ensure the paths in your script are correct and that the application pool user has the correct permissions.

Troubleshooting Tips

  • Check Execution Policy: Make sure the execution policy for PowerShell scripts (if any are involved) is not restrictive.
  • Logs and Diagnostics: Use UiPath logs and IIS logs for detailed diagnostics.
  • Use Full Paths: Always use full paths in your PHP script to avoid issues with relative paths.

By following these steps, you should be able to start a UiPath Robot from your local IIS site running PHP. If you still encounter issues, the error messages in Event Viewer and logs will be crucial for diagnosing and resolving specific problems.

Thank you for your detailed reply.

I would like to try out the multiple causes and setting points you suggested one by one.

I will try it out and will contact you separately.

Thank you

I checked all the settings and precautions you suggested, but the problem could not be resolved.

Instead, I was able to solve it in another way.

It can now be started by calling UiRobot.exe via the task scheduler.
As a point
・Set the correct execution user
・Set “Run only when logged on”

Please close this matter.

1 Like

perfect, I am glad you got it resolved.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.