Can't seem to get it right: Win NT registry save and load

logistix logstx at bellatlantic.net
Sat Mar 2 14:58:52 EST 2002


What exactly are you trying to accomplish?

RegLoadKey and RegSaveKey don't necessarily have the best names.  They are
designed to load and save entire registry hives (such as the ntuser.dat
located under each user profile).  RegLoadKey binds to the registry and
RegSaveKey saves the hive (generally for backup purposes).  If you bind a
hive to the registry and make changes to various keys with RegSetKey,
RegSetValue, etc and then Unload it, the changes will be saved.

Some problems you might experience with RegSaveKey:
    -You can't save a file inplace.  Loading a user's ntuser.dat file,
making changes and saving won't work because ntuser.dat will be locked when
you try to save the file.  Furthermore, you don't need to "save" the reg
entry to persist your changes.

    -You need "backup" privledges on the registry hive, which generally
means you need to be an administrator.  This is done for security reasons.
For example, one easy way to break into an NT box (assuming you have
physical access) is to run a repair operation on the system after you've
replaced the backup registry files with an admin account/password that you
know.

Outside of python, you might want to play with the tool Reg.exe and
regedt32.exe to get a better handle for how things work.  Reg.exe got moved
from the NT4.0 Resource Kit CD to the W2K Support tools (that can be found
on the install CD under the "Support" subdirectory)

Have fun (and don't go to crazy with the registry on a production box.  I
just fried mine!)


--
-

"Matthias Janes" <matthias_j at lycos.com> wrote in message
news:d7d5ebdf.0203010908.113324ea at posting.google.com...
> Hi I would like in a python script to save a Win NT Registry entry to
> a file and load it later -
> but it's seems I can't get it right.
>
> win32api.RegSaveKey
> RegSaveKey(key, filename, sa)
>
> I could not realy figure out the 3 part (sa )
>
> get always a error about the security rights.
>
> after I saved it how could I load it again?
>
>  Any Help would be real nice.
>
> Matthias Janes





More information about the Python-list mailing list