1
我正在尝试使用Windows注册表来查找程序的安装位置。我设法找到了我需要的关键和价值。它们位于Software \ Microsoft \ Windows \ CurrentVersion \ Uninstall文件夹中。但是,当我运行以下脚本时,它无法找到该文件。Python:查找注册表以查找程序的安装位置
from _winreg import *
aReg = ConnectRegistry(None,HKEY_LOCAL_MACHINE)
aKey = OpenKey(aReg, r'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall', 0, KEY_READ)
[Pathname,regtype]=(QueryValueEx(aKey,"InstallLocation"))
print Pathname
CloseKey(aKey)
CloseKey(aReg)
回溯:
Traceback (most recent call last):
File "C:\Users\m.armstrong\Desktop\regression\regpy.py", line 7, in <module [Pathname,regtype]=(QueryValueEx(aKey,"InstallLocation"))
WindowsError: [Error 2] The system cannot find the file specified
它是如何,我可以看到的关键,但似乎无法对其进行访问。
如果我指定的aKey =打开项确切的程序(AREG,r'SOFTWARE \微软\的Windows \ CurrentVersion \卸载\安道尔SDK_is1' ,0,KEY_READ)。它只会找到这个程序的安装位置。我已经尝试过了,它会像上面那样返回回溯。 – Marmstrong
@Marmstrong:你确定你的名字完全正确吗?你有没有尝试过使用'EnumKey'来查看所有的键,看看它是否显示? – abarnert