Nicolas Formichella
unread,May 3, 2022, 5:31:25 AM5/3/22You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
Hello,
I am encountering an issue with winreg, I can't figure out how to read the "(Default)" of a registry value
```
def get_chrome_version() -> str:
with winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER) as registry:
with winreg.OpenKeyEx(registry, r"Software\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe",
access=winreg.KEY_READ) as key:
value, _ = winreg.QueryValueEx(key, "(default)")
return value
```
Taking the example above it raises a FileNotFoundError :
```
Traceback (most recent call last):
File "C:/Users/noulo/dev/py/chromedriver_dl/main.py", line 14, in get_chrome_version
value, _ = winreg.QueryValueEx(key, "(default)")
FileNotFoundError: [WinError 2] The system cannot find the file specified
```
(Trying "Path" instead of "(Default)" works)
Although the value definitely exists as shown by Powershell
```
Get-Item -Path "HKCU:/Software/Microsoft/Windows/CurrentVersion/App Paths/chrome.exe" | Select-Object -ExpandProperty Property
```
Returns :
```
(default)
Path
```
Is this a bug I should report, or if not, what is the way, using winreg, to access the "(Default)" value of a key?
Regards,
Nicolas FORMICHELLA