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

Dahlstrom, Roger rdahlstrom at directedge.com
Fri Dec 5 15:41:36 CET 2008


If you can read the registry, you can save it without any other special permissions.  It is just text.

Just export a branch of your own registry and open it with notepad to see the format.  I do it all the time, it works fine.


-----Original Message-----
From: python-win32-bounces+rdahlstrom=directedge.com at python.org [mailto:python-win32-bounces+rdahlstrom=directedge.com at python.org] On Behalf Of Tim Golden
Sent: Friday, December 05, 2008 9:41 AM
Cc: python-win32 at python.org
Subject: Re: [python-win32] Walking the registry and creating reg files

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
_______________________________________________
python-win32 mailing list
python-win32 at python.org
http://mail.python.org/mailman/listinfo/python-win32


DISCLAIMER:
This e-mail, and any attachments thereto, is intended only for use by the addressee(s) named herein and
may contain legally privileged and/or confidential information. If you are not the intended recipient
of this e-mail, you are hereby notified that any dissemination, distribution or copying of this e-mail, and 
any attachments thereto, is strictly prohibited. If you have received this in error, please immediately notify 
me and permanently delete the original and any copy of any e-mail and any printout thereof. 
E-mail transmission cannot be guaranteed to be secure or error-free. The sender therefore does not accept 
liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission.

NOTICE REGARDING PRIVACY AND CONFIDENTIALITY
Direct Edge ECN LLC may, at its discretion, monitor and review the content of all e-mail communications.

www.directedge.com


More information about the python-win32 mailing list