Reply with quote Edit/Delete this post Delete this post Post _winreg.SaveKey question Does anyone know where I might find some sample code of using the saveKey function? I am getting an error 5 access denied and I think that it is coming from the way I am specifying the filename as in _winreg.SaveKey(key, filename). The docs mention that if the key is to a remote host (which it is in my case) that the path is relative. I read this as meaning that I should use a unc path back to where I want to save the registry key file. Here is a section of the code I am using:
def remoteSaveKey(host, key, file): rhostreg = _winreg.ConnectRegistry(host, _winreg.HKEY_LOCAL_MACHINE) remotekey = _winreg.OpenKey(rhostreg, key) _winreg.SaveKey(remotekey, file) ... from main(): readfile = open('hostlist.txt', 'r') hostfile = [] for host in readfile: hostfile += [host.strip()] for srvname in hostfile: outputpath = destsrvr + srvname # destsrvr is server/share outputfile = outputpath + "\\" + srvname output = remoteSaveKey(hostname, regpath, outputfile) I am able to connect to the registry and I believe that the key is being specified correctly, but I am getting the following error: Traceback (most recent call last): File "main.py", line 40, in ? output = remoteSaveKey(srvname, regpath, outputfile) File "main.py", line 17, in remoteSaveKey _winreg.SaveKey(remotekey, file) WindowsError: [Errno 5] Access is denied I have searched but have only been able to find documentation with little to no examples on how to implement the SaveKey function with a remote host. Any help will be appreciated. thx -- http://mail.python.org/mailman/listinfo/python-list