get registry information in python

Matt Gerrans mgerrans at
Fri Aug 16 08:51:55 CEST 2002

If you are working from Microsoft's VBScript (ugh) examples (or even the
slightly more palatable, but unfortunately not as ubiquitous JScript
examples), it might be easiest to simply translate them to Python with the
minimum amount of rewriting by using win32com.client, like so:

oRegistry = win32com.client.GetObject(
"winmgmts:{ImpersonationLevel=Impersonate}//" +
   HostName +
   "/root/default:StdRegProv" )

Now you can use the oRegistry almost exactly as it is used in the VBScript.
This is assuming that the VBScript version actually works on your system and
that you don't have other problems like insufficient permissions, as
discussed by James Besemer in his response.

I often use the "Scripting.FileSystemObject" on the Windows platform,
because it is often much simpler than os or shutil methods for copying or
deleting whole directory trees.

- Matt

More information about the Python-list mailing list