I want to make an app that launches different exe's but I have a problem, one app requires to run as admin, so my question is how can I run that app as admin from a python script?
Asked
Active
Viewed 660 times
0
-
1I think you'll need to manually run the script that launches the .exes as admin — otherwise there would be no security because anything could give itself admin privileges. On Windows I think that means using the `runas` command. – martineau Sep 20 '20 at 21:47
-
You don't run other processes with `os` (`os.system` is a terrible tool for subprocesses), you use the `subprocess` module. I suspect the answer to your question is in [Python 3: How to use subprocess.run() as admin (windows 10)](https://stackoverflow.com/q/60214168/364696), but I'm not sure enough to use my badge hammer to dupe to it. – ShadowRanger Sep 20 '20 at 21:47
-
You can use pywin module to run application with UAC prompt like that: `win32api.ShellExecute(None, 'runas', 'calc', None, None, win32con.SW_SHOWNORMAL)` – viilpe Sep 21 '20 at 12:05