The winreg Module Manipulate the Windows Registry

PC Repair Tools

Advanced Registry Cleaner PC Diagnosis and Repair

Get Instant Access

The Windows Registry is a database that contains program and system information and settings. Often it can be useful to access the Registry (to read from it or write to it) via a script. The winreg module makes this easy to do in Python.


The following example queries a particular key in the Registry and outputs all the subkeys for that key:

import _winreg explorer = _winreg.OpenKey(



# list values owned by this registry key i = 0


while 1:

name, value, type = _winreg.EnumValue(explorer, i) print repr(name), i += 1

except: print

The following is the output for this program:


'ShellState' 'CleanShutdown' 'Browse For Folder Width' 'Browse For Folder Height ' 'link' 'Logon User Name'

Was this article helpful?

0 0

Post a comment