I'm trying to get an UAC elevation from within a python script. I need it to execute a command (I'm on windows 10) : netsh winhttp set proxy xxxxxxx, because it requires admin privileges.
To get them, I use this code I found :
import os
from elevate import elevate
elevate(show_console=False)
os.popen('netsh winhttp set proxy 62.210.172.164:3128')
And this works perfectly, but then I got this :
Traceback (most recent call last):
File "TESTS 2.py", line 3, in <module>
elevate(show_console=False)
File "C:\Users\Elève\AppData\Local\Programs\Python\Python37-32\lib\site-packages\elevate\__init__.py", line 22, in elevate
elevate(show_console, graphical)
File "C:\Users\Elève\AppData\Local\Programs\Python\Python37-32\lib\site-packages\elevate\windows.py", line 89, in elevate
sys.exit(ret.value)
SystemExit: 0
There is an unwanted system exit, that is pretty annoying, and it seems it's an error... Do any of you know how can I fix this ? Or got any other way to elevate my script with UAC privilages ? Knowing that I need to execute many command and don't want a confirmation of elevation for each one, I need to elevate the whole script... Thank you if you can help by any way !