[python-win32] Walking the registry and creating reg files
Tim Golden
mail at timgolden.me.uk
Fri Dec 5 15:40:34 CET 2008
Mike Driscoll wrote:
> Tim Roberts wrote:
>> 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?
>>>
>>
>> I'm not answering the question you asked, but are you aware of the very
>> handy "reg" tool included with XP? "reg export" can export a full key
>> in a format that is compatible with regedit.
>> reg export HKLM\system\CurrentControlSet\Services\vgasave xxx.reg
>>
>>
>
> I suppose I should have completely explained the project, but I didn't
> think the other details mattered. I will be running this as part of my
> login script, and writing each subfolder to a directory tree on a per
> user basis. We are trying to figure out which users have which sessions
> of a certain program and how to best manage said sessions and their
> respective configurations, hence the audit.
As far as I can see, Mike, there's nothing in your description which
prevents you from using the registry's save/restore functionality:
http://timgolden.me.uk/python-on-windows/programming-areas/registry/save-and-restore-the-registry.html
There are bits in there which are a little out-of-date since pywin32 212
which added stuff, but basically the approach should work. You can save
the user's folder tree and then -- if you need -- pull the file to some
other machine and load it into a different tree. The user running the
save operation will need backup privs, however. Might be a showstopper.
TJG
More information about the python-win32
mailing list