-3

"C:\Users\AppData\Local\UiPath\app-19.7.0\UiRobot.exe" /file "C:\Users\Documents\UiPath\ThirdProcess\Main.xaml"

I need to execute this script from CMD only, as I am doing other API creation in my python code.

I am expecting to run one RPA bot using this script execution and then I will perform other data fetching task from the python API code.

4
  • First use os.environ.get or os.getenv to get string value of Windows environment variable LOCALAPPDATA which holds the path to local application data path of current user. I doubt that there is really C:\Users\AppData\Local\UiPath\app-19.7.0\UiRobot.exe as the account name is missing in this path. Concatenate this string with \UiPath\app-19.7.0\UiRobot.exe to get full qualified file name of the executable to run. Commented Jul 20, 2019 at 7:35
  • Next use again os.getenv to get string value of Windows environment variable USERPROFILE and concatenate it with string \Documents\UiPath\ThirdProcess\Main.xaml to get full qualified file name of the XAML file. Next use os.path.isfile two times with both file names to verify if the executable and the XAML file really exist. Then use subprocess module to run the executable with the XAML file as argument. Commented Jul 20, 2019 at 7:41
  • If you think reading Python documentation is not worth the time (which is definitely not true), you can find related questions and answers for the few lines of Python code for this task also on Stack Overflow. See for example How to access environment variable values?, How do I check whether a file exists without exceptions? Python subprocess call with arguments having multiple quotations. Commented Jul 20, 2019 at 7:47
  • @Mofi , yes Agree with you on above points, I need to think first to build or finalize an approach for any problems. new in python and stack-overflow , now will make such habits. thank you . and yes I do find difficultly in understanding Python officially documentation. Commented Jul 22, 2019 at 14:01

2 Answers 2

0

I'm not entirely sure what you're trying to do with these programs, but it looks like you could use Popen. There's a similar post here if you want to look at it.

import subprocess
myCmd = "C:\Users\AppData\Local\UiPath\app-19.7.0\UiRobot.exe"
subprocess.Popen(myCmd)

and if you had multiple commands you could loop through a list

import subprocess
myCmds = ["C:\Users\AppData\Local\UiPath\app-19.7.0\UiRobot.exe", "C:\Users\Documents\UiPath\ThirdProcess\Main.xaml"]
for Cmd in myCmds:
    subprocess.Popen(Cmd)
Sign up to request clarification or add additional context in comments.

2 Comments

Hi @Isaiah, yes I need to use Popen of subprocess module. but this below script is not working for me, I need to pass all 3 piece of code in single line to commad prompt. to run one .exe file with file location as a arg. please help me here import subprocess subprocess.popen(["C:\Users\AppData\Local\UiPath\app-19.7.0\UiRobot.exe", "/file", "C:\Users\Documents\UiPath\ThirdProcess\Main.xaml"]) this one line is working fine in Command prompt:- "C:\Users\AppData\Local\UiPath\app-19.7.0\UiRobot.exe" /file "C:\Users\Documents\UiPath\ThirdProcess\Main.xaml"
I'm not sure how to add the /file in python But You might be able to make a batch file and launch it through python makeuseof.com/tag/… or a shortcut with the /file argument
0

Below code helped me to achieve this functionality.

subprocess.call([
    'C:\\Users\\shubham\\AppData\\Local\\UiPath\\app-19.7.0\\UiRobot.exe',
    '/file',
    'C:\\Users\\shubham\\Desktop\\FinalOCR\\InvoiceAutomation\\PDFReadwithNative.xaml'
])

Thank you everyone.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.