Orc: OrchestratorRerunAsAdmin save the prev process env

dev-fastapi
Ivan Maslov 2 years ago
parent b1e6932180
commit 90577582af

@ -647,8 +647,12 @@ def OrchestratorRerunAsAdmin():
:return: True - Запущен с правами администратора; False - Не запущен с правами администратора
"""
if not OrchestratorIsAdmin():
if "PYTHON_CONFIGURE" in os.environ:
# Re-run the program with admin rights
ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, " ".join(sys.argv), None, 1)
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"Уже запущено с правами администратора!")

Loading…
Cancel
Save