Newbie Windows Registry Question

Stacy stacycollings at yahoo.com
Tue Jul 13 17:45:03 CEST 2004


Hi Nick,

Yes, I am having the same error message.  I found some info on the
Microsoft page regarding error 1314 and Windows 2000...they made a
patch to fix it.  I was unable to find anything relating to this
problem specifically for XP...hmmm. I wonder if it may have something
to do with my virus/firewall software....I'll keep looking.  Thanks
for the help!

Stacy

"Nick Smallbone" <nick at nick8325.freeserve.co.uk> wrote in message news:<40f2d2a3$0$7804$db0fefd9 at news.zen.co.uk>...
> "Stacy" <stacycollings at yahoo.com> wrote in message
> news:c7c55926.0407120913.6292e61c at posting.google.com...
> > Hi All,
> >
> > I'm trying to automate some migration tasks on XP and one of the steps
> > involved is to export a reg key to install on a new machine.  After
> > days of surfing the web and trying things, I give!Ineedsome newbie
> > help.  What I want is to export the given key to my USB drive for
> > later import to the new machine's registry.  The Python code I've
> > written also copies User files, favorites, etc...Here's an example of
> > what I have tried as far as the reg key goes:
> >
> > import _winreg
> > _winreg.SaveKey(hkey_local_machine\software\adobe,
> > r"C:\Python23\samplekey.reg")
> >
> > This gives the following error:
> > SyntaxError: invalid token
> >
> > Okay, so then I tried this:
> > _winreg.SaveKey(r"hkey_local_machine\software\adobe",
> > r"c:\python23\samplekey.reg")
> >
> > And I get this error message:
> > TypeError: The object is not a PyHKEY object
> >
> > Any idea what I am doing wrong?
> >
> > Thanks!
> >
> > Stacy :)
> 
> Hmm, the first parameter to SaveKey needs to be an HKEY object. You can get
> one of these by calling _winreg.OpenKey. So for example:
> 
> import _winreg
> key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "Software\\Adobe")
> _winreg.SaveKey(key, "c:\\python23\\samplekey.reg")
> 
> However, when I do that, I get a WindowsError: A required privilege is not
> held by the client. The documentation says that SeBackupPrivilege is needed
> to call SaveKey. It happens when I run it as administrator as well though,
> so I'm not sure what's happening there.
> 
> Nick



More information about the Python-list mailing list