Quantum Sushi
Quantum Sushi

Reputation: 514

UAC elevation with python : unwanted system exit with elevate module

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 !

Upvotes: 0

Views: 417

Answers (3)

lb54
lb54

Reputation: 11

I found the IP of my dedicated server on Stackoverflow by Googling the IP after I receive abuse report on my IP ... due to this mistake on squid server :( So that's why I answer you :)

Upvotes: 0

Quantum Sushi
Quantum Sushi

Reputation: 514

I fixed my problem ! First, I did pip show elevate in the cmd to get the location of the library script, then I opened it with python and just removed the last line, sys.exit(ret.value)... And that's all, it works perfectly now haha !

Upvotes: 0

Lo&#239;c BASTER
Lo&#239;c BASTER

Reputation: 21

It will never work because I'm the owner of the IP 62.210.172.164 and I have a mistake in Squid configuration, so the proxy is now closed !

Upvotes: 2

Related Questions