[python-win32] COM registration/unregistration and elevation on Vista
timr at probo.com
Fri Jan 18 19:02:06 CET 2008
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
An application with "setup" or "install" or "update" in its filename
automatically gets elevated. I wonder if it would be possible to create
a clone of Python.exe called PythonSetup.exe and use that for
registration? I guess that's not really better than your solution.
You're right, there are no perfect answers.
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the python-win32