[python-win32] COM registration/unregistration and elevation on Vista

Roger Upole rwupole at msn.com
Sat Jan 19 09:44:49 CET 2008


"Tim Roberts" <timr at probo.com> wrote in message 
news:4790E99E.3040506 at probo.com...
> Mark Hammond wrote:
>> On Vista, it's necessary to register python COM objects from an 
>> "elevated"
>> process.  In practice, this means I tend to keep a command-prompt open
>> started with "run as administrator", do registration and unregistration
>> there, then switch back to the normal command-prompt to do testing etc. 
>> I
>> finally got annoyed at this, and came up with a patch that catches this
>> error, then retries the command after prompting for elevation (the 
>> infamous
>> Vista "Allow" dialog).
>> ...
>> As a result, I'd like some feedback on my approach - both the specific
>> implementation and the general idea, or anything else you can think of.
>> I've attached the patch.
>>
>
> It is possible (since XP) to register a COM object in
> HKEY_CURRENT_USER\Software\Classes instead of
> HKEY_LOCAL_MACHINE\Software\Classes (which is HKEY_CLASSES_ROOT).
> Writing to HKCU should not require elevation.  However, as you might
> expect, that results in a COM object that is usable only by the current
> user.
>

A while back, I made some modifications to register.py to allow this, but
ran into a couple of roadblocks.

If the server has a typelib, RegisterTypeLib is called, which requires admin
privs.  There is RegisterTypeLibForUser, but it's not available on Win2k.
It should be possible to duplicate the keys created, but it will take some
research to identify them.

PyICatRegister.RegisterClassImplCategories also fails for a non-admin user,
and there doesn't appear to be any per-user call for this interface.
Anybody know if this is strictly necessary, or what the consequences of
omitting it are ?

               Roger



More information about the python-win32 mailing list