winreg 导出注册表 OSError: [WinError 1314] 客户端没有所需的特权。
各位大哥,以下代码,想把 HKEY_LOCAL_MACHINE\SOFTWARE\123456 键下所有注册表值备份导出到mykey.reg文件,运行后权限报错,求解决方案程序代码:
import winreg reg_root = winreg.HKEY_LOCAL_MACHINE reg_path = r'SOFTWARE\123456' reg_permission = winreg.KEY_ALL_ACCESS reg_name = 'PS_VendorSPVersion' key = winreg.OpenKeyEx(reg_root, reg_path, 0, reg_permission) data, regType = winreg.QueryValueEx(key, reg_name) print(data) winreg.SaveKey(key, "mykey.reg")
运行结果:
程序代码:
D:\python3.7.0\python.exe E:/Python_Project/Chenb_Test/myapp/test.py V1.2.2 Traceback (most recent call last): File "E:/Python_Project/Chenb_Test/myapp/test.py", line 11, in <module> winreg.SaveKey(key, "mykey.reg") OSError: [WinError 1314] 客户端没有所需的特权。 Process finished with exit code 1