[python-win32] Walking the registry and creating reg files

Tim Golden mail at timgolden.me.uk
Fri Dec 5 10:18:16 CET 2008


Mike Driscoll wrote:
> We're doing what amounts to a registry session audit here at work, so I 
> need to walk a specific set of subfolders in our registry and get the 
> contents thereof. The subfolders will vary from user to user. I found 
> Tim Golden's excellent registry walking script on his website here:
> 
> http://timgolden.me.uk/python-on-windows/programming-areas/registry/walk-the-registry.html 
> 
> 
> My problem is that I need to output the data into *.reg files. Is there 
> a builtin way to do that with _winreg or PyWin32 or do I just need to 
> roll my own?

Try as I might, I was unable to discover an API to do this. The
backup/restore APIs create opaque binaries. Shouldn't be too hard
to get a simple version up-and-running, but picking up all the nuances
of different data types might be a bit tedious[*]. If you decide to do
something and get it running, please do post it back. I have a
long-in-gestation winsys package:

http://winsys.googlecode.com/svn/trunk

which has a registry module
which could do with such a routine. I had thought about writing
it myself but considered it low priority. I'm hoping that once
I get this -- frankly enormous -- package out with docs & tests
I'll be able to feed the best bits of it, and of my own experience,
back into the docs you reference above which have been sadly
neglected.

TJG

[*} One note which I remember: the .reg files are usually UTF16LE;
not sure if that's important or not.


More information about the python-win32 mailing list