Q:

Python subprocess to execute external Command prompt scripts, trying to run one .exe file by passing file location

I have to run one .exe file(RPA bot) using python code, later in that same code I might have to write other functionality as well for API creation. right now I am writing this code from Jupyter Notebook.
subprocess module's "popen" and "call" I have already tried by passing as a all type of strings.
Command Prompt Script which I have run from python:- 
`"C:\Users\shubham.f.jain\AppData\Local\UiPath\app-19.7.0\UiRobot.exe" /file "C:\Users\shubham.f.jain\Desktop\FinalOCR\InvoiceAutomation\PDFReadwithNative.xaml"
Python Code which is not working:-
import subprocess

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

I tried above code with passing all 3 arg as a separate strings as well.

A:

You need to escape the backslash and split the command into a list of strings, so your Python code would look like:
subprocess.call([
    'C:\\Users\shubham.f.jain\\AppData\\Local\\UiPath\\app-19.7.0\\UiRobot.exe',
    '/file',
    C:\\Users\\shubham.f.jain\\Desktop\\FinalOCR\\InvoiceAutomation\\PDFReadwithNative.xaml'
])

