我是python新手。我想使用python脚本删除注册表中的密钥。如何使用python脚本从注册表中删除一个应用程序的注册表项?
注册表编辑器树视图我的应用程序键
HKEY_CURRENT_USER
|
|_Software
|
|_Applications
|
|_Application
|_Test1
|_Test2
在此,我想删除使用python脚本 Test1的关键。
我用下面的脚本
import _winreg
Key_Name=r'Software/Applications/Application/Test1'
Key=_winreg.OpenKey(_winreg.HKEY_CURRENT_USER, Key_Name, 0, _winreg.KEY_ALL_ACCESS)
_winreg.DeleteKey(key)
错误:
Traceback (most recent call last):
File "C:\Users\Test\workspace\Test\DeletePreferences.py", line 9, in <module>
key=_winreg.OpenKey(_winreg.HKEY_CURRENT_USER, r'Software/Applications/Application/Test1', 0, _winreg.KEY_ALL_ACCESS)
WindowsError: [Error 2] The system cannot find the file specified
任何人可以提出该解决方案?
错误似乎很清楚 - 在注册表中的键没有被发现(最有可能的,因为它不存在) –