From 90577582af1b4fe7fc53c83644ef40918c5352f4 Mon Sep 17 00:00:00 2001 From: Ivan Maslov Date: Wed, 26 Oct 2022 23:40:29 +0300 Subject: [PATCH] Orc: OrchestratorRerunAsAdmin save the prev process env --- Sources/pyOpenRPA/Orchestrator/__Orchestrator__.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Sources/pyOpenRPA/Orchestrator/__Orchestrator__.py b/Sources/pyOpenRPA/Orchestrator/__Orchestrator__.py index a04da3ac..f7b702a7 100755 --- a/Sources/pyOpenRPA/Orchestrator/__Orchestrator__.py +++ b/Sources/pyOpenRPA/Orchestrator/__Orchestrator__.py @@ -647,10 +647,14 @@ def OrchestratorRerunAsAdmin(): :return: True - Запущен с правами администратора; False - Не запущен с правами администратора """ if not OrchestratorIsAdmin(): - # Re-run the program with admin rights - ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, " ".join(sys.argv), None, 1) + if "PYTHON_CONFIGURE" in os.environ: + # Re-run the program with admin rights + ctypes.windll.shell32.ShellExecuteW(None, "runas", "cmd", " ".join(["/C", "cd", f'"{os.getcwd()}"', "&&",f'"{os.environ["PYTHON_CONFIGURE"]}"',sys.executable]+sys.argv), None, 1) + else: + # Re-run the program with admin rights + ctypes.windll.shell32.ShellExecuteW(None, "runas", "cmd", " ".join(["/C", "cd", f'"{os.getcwd()}"', "&&", sys.executable,sys.argv]), None, 1) else: - print(f"Уже запущено с правами администратора!") + print(f"Уже запущено с правами администратора!") def OrchestratorPySearchInit(inGlobPatternStr, inDefStr = None, inDefArgNameGSettingsStr = None, inAsyncInitBool = False, inPackageLevelInt = 0): """L+,W+: Выполнить поиск и инициализацию пользовательских .py файлов в Оркестраторе (например панелей управления роботов)