0

I am starting SAP GUI through subprocess. However, I need it to start in administrator mode. What do I need to change in the code?

path = r"C:\Program Files (x86)\SAP\FrontEnd\SAPgui\saplogon.exe"
subprocess.Popen(path)
time.sleep(3)

SapGuiAuto = win32com.client.GetObject("SAPGUI")

if not type(SapGuiAuto) == win32com.client.CDispatch:
    print('return')

application = SapGuiAuto.GetScriptingEngine
connection = application.OpenConnection("ECC QAS", True)
time.sleep(3)
session = connection.Children(0)

try:
    session.findById("wnd[0]/usr/txtRSYST-MANDT").text = "300"
    session.findById("wnd[0]/usr/txtRSYST-BNAME").text = 'USER' #USUARIO
    session.findById("wnd[0]/usr/pwdRSYST-BCODE").text = 'PASSWORD' #SENHA
    session.findById("wnd[0]/usr/txtRSYST-LANGU").text = 'PT' #IDIOMA
    session.findById("wnd[0]").sendVKey(0) #ENTER
    
except:
    print(sys.exc_info()[0])
Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Brandalize
  • 21
  • 6
  • https://stackoverflow.com/questions/47380378/run-process-as-admin-with-subprocess-run-in-python – jprebys Feb 03 '23 at 18:32
  • Does this answer your question? [Run process as admin with subprocess.run in python](https://stackoverflow.com/questions/47380378/run-process-as-admin-with-subprocess-run-in-python) – Sandra Rossi Feb 03 '23 at 18:47

0 Answers0