Before anything, I know how to run a simple process via a powershell script
Ok so I have two questions :
First of all, I want to use a Python script (which is firstly called from a WinDev program fyi) to run a uirobot process. And I don’t know how. Is there a way in Python to do so ? Or will I be forced to run a Powershell from my Python script ?
Second question, How do I pass arguments to the process, and how are they gathered from the process. To further explain, I need to pass dates (as strings) as parameters for the UiPath process, as it was build to find stuff based on the dates you input. So if I were to call the process via Powershell, or even if there was a way to run the script from Python directly, how would it be done ?
No need to answer both of the questions at the same time, I just need a few info and I’ll be able to figure out by myself at some point. But in case people knew, it would spare me time
Well, actually, this is the opposite of what I’m willing to do.
This shows how to run a Python script with arguments from a UiPath Process.
What I want to do is run a UiPath Process with arguments from a Python script.
To be clear, the first thing launched in my build is Python.
Now I imagine in my Python script, there’s a line like “runUiRobotProcess(arg1,arg2,arg3)”
Though, my question is, how do I write that to make it work ? How can I run an UiRobot process from a Python script formula
Ah ok, now I understand your request. So lets break it down. This is surely possible. The os module in python is all you need.
What you must have in the host system running your python script
At a minimum a UiPath robot license (since 21.10 UiRobot.exe does not run headless/airgapped anymore, it has to be connected to the orchestrator and a license must be allocated)
General syntax : Hey UiRobot.exe, execute a nuget file with input arguments and use a specific entrypoint
def RunningUiPathProject(arg1):
"""
You can design this function as you please with any number of arguments going into the cmd_str variable
"""
import subprocess
cmd_str = "C:\Users\%USER%\AppData\Local\Programs\UiPath\Studio\UiRobot.exe execute --file 'C:\Users\%USER%\Documents\UiPath\_Nugets\YourUiPATHPROJECT.1.0.3.nupkg' --input '{'in_InputDataFolder':ARG1} --entry 'YOURENTRYPOINT.xaml'".Replace("ARG1",arg1)
subprocess.run(cmd_str)
The one thing I have not tested is the use of Quotes in cmd_str. Quotes are always a pain, at the worst case save the cmd_str variable in a text file and read it and then manipulate it, much like a template string.
Thanks for all of this, this is perfect. I figured out some of this myself this morning and was able to test and deploy Indev version of my project with this info. You have perfectly resumed it and I hope that some other people will find and use your solution in the future as it’s insanely useful !
To resume for curious people :
In Python, use the “subprocess” module. The .run() function is the key, just need to paste the same string you would have put in a CMD or PowerShell
For UiPath input entry, simple define Arguments as “In” or “In/Out” format. In the string used in Python, you need to add “–input <variables in a json/dict format surrounded by quotes>” (see example above)
You need to have a license on your UiRobot connected to the orchestrator to fetch the process and be able to run it (same as if you were to run the process from the UiPath Assistant)
If for some reason, anyone needs to connect this with a WinDev window as front-end, you just need to specify the arguments as parameters of the function you’re calling. If help needed, you can DM me