简体   繁体   中英

Python: Unable to open a new command prompt session and run a program through command line (windows) using Python script

My Python script is running in one cmd session and I want to open a new cmd session and run the below file -

C:\\Users\\nilabja.saha\\AppData\\Local\\UiPath\\app-19.10.1\\UiRobot.exe execute --file "C:\\Users\\nilabja.saha\\Documents\\UiPath\\TriggerXXX\\Main.xaml"

[It is an UiPath file which can be triggered from CMD in this way..]

Is this at all possible to run this using Python? Please help.

Using subprocess, I could reach till the end of the path, but then could not execute the file.. (below is the code)

subprocess.Popen('cmd.exe /K cd /Users/nilabja.saha/AppData/Local/UiPath/app-19.10.1')

Please help!

from telegram.ext import Updater
updater = Updater(token='tokentoken', use_context=True)
dispatcher = updater.dispatcher
import logging
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.INFO)

import subprocess
subprocess.call([r'C:\Users\UserName\AppData\Local\UiPath\UiPath.Agent']) 
def start(update, context):
   context.bot.send_message(chat_id=update.effective_chat.id, text="Start")

updater.start_polling()

#import os
def echo(update, context):
    #import subprocess
    context.bot.send_message(chat_id=update.effective_chat.id,  text=   'Processing...')
    file = context.bot.getFile(update.message.photo[-1].file_id)
    print ("file_id: " + str(update.message.photo[-1].file_id))
    #file.download(str(update.effective_chat.id) + '.jpg')
    file.download('C://Users//UserName//Documents//UiPath//PROJECT//' + str(update.effective_chat.id) + '.jpg')
    #from pywinauto.application import Application
    #from pywinauto.keyboard import SendKeys
    import win32com.client as comclt
    wsh = comclt.Dispatch("WScript.Shell")
    wsh.AppActivate("UiPath.Agent") 
    wsh.SendKeys("^t") 

from telegram.ext import MessageHandler, Filters
echo_handler = MessageHandler(Filters.photo, echo)
dispatcher.add_handler(echo_handler)

def echoText(update, context):
    context.bot.send_message(chat_id=update.effective_chat.id, text='TalK')

from telegram.ext import MessageHandler, Filters
echo_handler = MessageHandler(Filters.text, echoText)
dispatcher.add_handler(echo_handler) </code> 

This is a sample of RunBat.bat - starts a Python server that listens a chatbot chanel if it finds a triger-picture it starts the UIPath bot in orchestrator

e

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM