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