Running compiled python (py2exe) as administrator in Vista

UnkwnTech picture UnkwnTech · Oct 12, 2008 · Viewed 7.8k times · Source

Is it possible to programaticly run compiled Python (comiled via py2exe) as administrator in Vista?

Some more clarification:
I have written a program that modifies the windows hosts file (c:\Windows\system32\drivers\etc\hosts) in Vista the program will not run and will fail with an exception unless you right-click and run as administrator even when the user has administrator privileges, unlike in XP where it will run if the user has administration rights, so I need a way to elevate it to the correct privileges programaticly.

Answer

Ivaylo picture Ivaylo · Sep 18, 2009

Following the examples from Python2x\Lib\site-packages\py2exe\samples\user_access_control just add uac_info="requireAdministrator" to console or windows dict:

windows = [{
    'script': "admin.py",
    'uac_info': "requireAdministrator",
},]