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.
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:
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.
Configure IIS and PHP: Make sure your PHP script can execute external programs and that the path to UiRobot.exe is correct.
Update PHP Script: Modify the PHP script to handle any potential permission issues and ensure it can correctly call the UiPath Robot executable.
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
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).
Grant Necessary Permissions
Ensure the user has “Log on as a batch job” rights:
Open Local Security Policy (secpol.msc).
Navigate to Local Policies → User Rights Assignment.
Find “Log on as a batch job” and add the application pool user.
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);
}
?>
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).
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.