Python – Running compiled python (py2exe) as administrator in Vista

permissionspy2exepythonwindows-vista

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.

Best Answer

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",
},]