You can try to capture the output of the PowerShell command that launches the UiPath process using subprocess.run() in Python. The subprocess.run() method returns a CompletedProcess object that has attributes like returncode and stdout that you can use to check if the process completed successfully or not.
To have the UiPath process return a value that can be captured by the PowerShell script, you can use the Write-Output cmdlet in PowerShell.
I can’t use #2 because I don’t call any Power Shell window into my UiPath process
For #1, this is what I thought and it works. Though it’s not the result I want, because I don’t only want to know when it crashes, but I want to know it’s status (since my process ends on different conditions, depending if a file has already been done or not).
To be clear on what my process does : It logs on to an app, tries to click a button that does something with a client folder. If the folder has already been treated by a co-worker, then it end. If it has not been treated, it tries to click the button. If the button gives an error, it does a loop to change folder setting before trying again. So I have a routine in case of some result. And my runs would return either “Crash”,“Done”,“Already done”. That’s more like something I would’ve wanted. Mostly like getting “checkpoint flags”
I still ran my process anyway because it’s just a process control system, nothing too important right now. But for later cases, I would want to get that info, and I think the only way is to output the “checkpoints” onto an external data file.
I got aware of the CompletedProcess object, and it currently catches something if the process crashes and returns it in CompletedProcess.stderr. Though for any other output, I don’t get anything in CompletedProcess.stdout.
I tried using either “Write Line” or “Log Message” activity on different levels, and nothing works (even Error or Fatal levels). I also tried using an Out Argument that could’ve appeared at the end of the process, but nothing
I’m sure it’s close to a result with the CompletedProcess object, but I can’t figure out why I get crashes messages but nothing else…
I’m gonna try the “Write-Output” cmdlet as another subprocess call before running the activities. I hope it keeps the same Powershell process for that !