[python-win32] COM registration/unregistration and elevation onVista

Roger Upole rwupole at msn.com
Sat Jan 19 05:29:39 CET 2008


"Mark Hammond" <mhammond at skippinet.com.au> wrote in message 
news:129101c85987$f2e09280$d8a1b780$@com.au...
> 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).
>
> However, it's not perfect;
> * a new process is created to perform the actual registration, and the
> output from this process is lost.  The normal ways of getting child 
> process
> will not work, as the child must be executed via ShellExecuteEx for the
> elevation to happen.  We can get the exit code of the process, but no
> output.
> * The elevation prompt simply says "python.exe" wants big-bad-scary access
> to your computer.  AFAIK, there is no way to have windows use a different
> string (ie, to indicate a com object is being registered)
> * It might be too magic - should this just be left as the responsibility 
> of
> the packager?  Will it interfere with "frozen" servers?
>
> 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.
>
> Thanks!
>
> Mark

Runas also works on XP, so you should be able to reduce the version check
by a notch.

Could you capture the output by adding ">somelogfile" to the passed args ?

For unattended installs, it might be helpful to have some way to suppress 
the
elevation attempt and just let it fail.

             Roger




More information about the python-win32 mailing list