[python-win32] Vista, _winreg and "Access denied"

le dahut le.dahut at laposte.net
Fri Jun 6 17:47:42 CEST 2008


To complete this, the application is launched at logon (via Userinit 
registry key). It rewrites paths to StartMenu and Desktop according to 
the type of logon (Domain or Local).
Actually it only rewrites when it is a local session and user IsAnAdmin. 
The application as to re-run itself using ShellExecute so it has to know 
if it already runs elevated or not.

To do this I must use :
GetTokenInformation(
                     hToken,
                     TokenElevationType
		    )

Unfortunately win32security.TokenElevationType (18) is not available. 
And GetTokenInformation(hToken, 18) returns
 >>> win32security.GetTokenInformation(hToken, 18)
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
pywintypes.error: (87, 'GetTokenInformation - size call', 'The parameter 
is incorrect')


Is it possible to do this using ctypes ? How ?




Tim Golden wrote :
> le dahut wrote:
>> Hello,
>> I've passed some time reading the MS coding guide for Vista 
>> http://msdn.microsoft.com/en-us/library/bb756973.aspx
>>
>> It explains that an app requiring administrator rights (modify HKLM, 
>> write in C:\Windows\, etc.) will always return "Access denied" or ask 
>> the user for UAC if it's launched with the appropriate manifest or 
>> with "runas".
>> You can personalize the UAC prompt by a short description of your 
>> program and an icon.
>>
>> In short, if your user app does something like that, rewrite it using 
>> a service.
> 
> Thanks for getting back with the info.
> 
> TJG
> 
> 
> 


More information about the python-win32 mailing list