[python-win32] _winreg.SaveKey question
Rodney McBride
rodneywmcbride at gmail.com
Thu Oct 26 13:18:46 CEST 2006
I am getting an access denied error when calling _winreg.SaveKey and I
believe that the error is being caused by not having the SeBackupPrivilege
set when calling the _winreg.SaveKey method for a remote host (I am
attempting to export a registry key from a remote host to a file for backup
purposes). My question is how do I set the 'SeBackupPrivilege'?
Here's a copy of my source code:
##################################
import os, string, sys, win32con, _winreg
def createFolder(path):
if os.path.exists (path):
pass # do nothing
else:
os.mkdir(path)
def remoteSaveKey(host, subkey, file):
rhostreg = _winreg.ConnectRegistry(host, _winreg.HKEY_LOCAL_MACHINE)
remotekey = _winreg.OpenKey(rhostreg, subkey, 0, _winreg.KEY_ALL_ACCESS)
_winreg.SaveKey(remotekey, file)
destsrvr = "\\\\server1\\backup$\\"
# Registry key (and all subkeys) to be processed for backup/restore
regpath = "Software\\Cisco Systems, Inc."
# Open hostfile and read hostnames into a list
readfile = open('d:\scripts\dev\SideAsrv.txt', 'r')
hostfile = []
for host in readfile:
hostfile += [host.strip()]
readfile.close ()
for srvname in hostfile:
outputpath = destsrvr + srvname
createFolder(outputpath)
outputfile = outputpath + "\\" + srvname
srvname = "\\\\" + srvname
# Call the function to connect to and export the remote registry key
output = remoteSaveKey(srvname, regpath, outputfile)
# DEBUG
print outputfile
# Select the next host
#####################
Thanks,
Rodney McBride
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20061026/f526262c/attachment.htm
More information about the Python-win32
mailing list