get registry information in python

James J. Besemer jb at
Thu Aug 15 08:13:00 EDT 2002

Steven Nien wrote:

> Thank you for your reply. I know how to using win32api or _winreg get
> registry data. For example:

> But the code can't run remotely for Win9x. (Win9x must install remotereg
> from Win9x CD) So I try to use Microsoft Windows Management Instrumentation
> (WMI) to get registry and hardware information.

I don't know about any of the above remote stuff or how it
contributes to your problem.

> I find scripts from Microsoft MSDN. For example:

If you know how to use _winreg and win32api then you should be able
to transliterate the visual basic example to Python.

The only complication that I see is

    Set oRegistry = _
        GetObject("winmgmts:{ImpersonationLevel=Impersonate}//" & _
        HostName & "/root/default:StdRegProv")

Which I surmise tries to connect to a remote registry hive.

I have no experience with the above VB construct but


should do same thing -- that is to connect you to a registry
on remote HostName.

The other gotcha: for ANY of this registry crap to work, you
(your program) must have the proper security permissions to
allow it to do whatever it's trying to do -- not just when you attach
to the hive but for each and every single step along the way.

Note that in addition to whatever global restrictions are in place,
you yourself can further restrict access at just about any point
along the way.  All the registry "open" functions have an optional
security mask parameter and the defaults aren't always what you

I have no idea how Windows security works between the various
Win platforms and that could be a continuing source of grief for you.



James J. Besemer  503-280-0838 voice  503-280-0375 fax
mailto:jb at

More information about the Python-list mailing list