Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Linux - Where do you want to fly today? -- Unknown source


devel / comp.lang.python / Re: [winreg] How to access "(Default)" key value?

SubjectAuthor
* [winreg] How to access "(Default)" key value?Nicolas Formichella
`- Re: [winreg] How to access "(Default)" key value?MRAB

1
[winreg] How to access "(Default)" key value?

<8cd15ae0-e6d9-478c-a4be-c354d221b07dn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18120&group=comp.lang.python#18120

  copy link   Newsgroups: comp.lang.python
X-Received: by 2002:ac8:7f4d:0:b0:2f1:f967:52bd with SMTP id g13-20020ac87f4d000000b002f1f96752bdmr13745023qtk.597.1651570274080;
Tue, 03 May 2022 02:31:14 -0700 (PDT)
X-Received: by 2002:ac8:4e43:0:b0:2f3:a20a:371e with SMTP id
e3-20020ac84e43000000b002f3a20a371emr9308690qtw.671.1651570273880; Tue, 03
May 2022 02:31:13 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Tue, 3 May 2022 02:31:13 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=80.14.199.69; posting-account=S6vSwgoAAAA2hRAJ6_KocvnZ5U8exgW6
NNTP-Posting-Host: 80.14.199.69
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <8cd15ae0-e6d9-478c-a4be-c354d221b07dn@googlegroups.com>
Subject: [winreg] How to access "(Default)" key value?
From: noulo...@gmail.com (Nicolas Formichella)
Injection-Date: Tue, 03 May 2022 09:31:14 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 40
 by: Nicolas Formichella - Tue, 3 May 2022 09:31 UTC

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

Re: [winreg] How to access "(Default)" key value?

<mailman.303.1651596560.20749.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18124&group=comp.lang.python#18124

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: pyt...@mrabarnett.plus.com (MRAB)
Newsgroups: comp.lang.python
Subject: Re: [winreg] How to access "(Default)" key value?
Date: Tue, 3 May 2022 17:46:12 +0100
Lines: 47
Message-ID: <mailman.303.1651596560.20749.python-list@python.org>
References: <8cd15ae0-e6d9-478c-a4be-c354d221b07dn@googlegroups.com>
<aa86d087-55de-7df8-80d9-cc8575919489@mrabarnett.plus.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de wn18QYwLSMFrYSDdLzfwVAKK6vqTYEJ2v/2nOiSx8SqQ==
Return-Path: <python@mrabarnett.plus.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=plus.com header.i=@plus.com header.b=QzhMMd8U;
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.002
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'def': 0.04; 'traceback':
0.04; '(most': 0.05; 'last):': 0.05; 'subject:value': 0.07;
'from:addr:python': 0.09; 'received:192.168.1.64': 0.09;
'from:addr:mrabarnett.plus.com': 0.16; 'from:name:mrab': 0.16;
'key:': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'nicolas':
0.16; 'none)': 0.16; 'none:': 0.16; 'received:plus.net': 0.16;
'string:': 0.16; 'wrote:': 0.16; 'instead': 0.17; "can't": 0.17;
'bug': 0.19; 'figure': 0.19; 'to:addr:python-list': 0.20; 'issue':
0.21; 'subject:: [': 0.21; 'subject:] ': 0.21; 'returns': 0.22;
'subject:How': 0.23; 'skip:- 10': 0.25; 'cannot': 0.25; 'header
:User-Agent:1': 0.30; 'empty': 0.32; 'specified': 0.32;
'received:192.168.1': 0.32; 'path': 0.33; 'header:In-Reply-To:1':
0.34; 'definitely': 0.35; 'using': 0.37; 'received:192.168': 0.37;
'file': 0.38; 'read': 0.38; 'use': 0.39; 'hello,': 0.40; 'should':
0.40; 'above': 0.62; 'received:212': 0.62; 'skip:r 40': 0.64;
'skip:w 20': 0.69; '"")': 0.84; 'report,': 0.84; 'skip:" 40':
0.84; 'skip:" 50': 0.84; 'property': 0.88; 'exists': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=plus.com; s=042019;
t=1651596373; bh=DpcukviwxTHmDCiYK803xdD6pqltf+xYrY0wBVox8ls=;
h=Date:Subject:To:References:From:In-Reply-To;
b=QzhMMd8UZ9DiwoD9ktrYfthgqkewHCdAlWuch+cq3EkKd2E/v1nnx27IoMhYSqTdz
IY+znrB+kJ6oX/sxjQacEGc3WW0CG3bXJjstq2g25vB1PXb8/Y92B/RAxXs4U7d09G
yuzCauSCqdWlEVoP5T+g7EjHBShs8UZvvPvxdBUgYdvkrxWrvrdN19lFbRCH1pEZCr
Nt74Stdrg4DYWC5pqpFQC1GhBTeHhfRTykz6jtPhiFF0szpz3zOX/MtwUbLFdumu8G
CBqdrGyVgS7n81KVSJg6d3gtYpr9ZsU8q4dpsP8yIyBha4Nr0mYY6/aCBqKMhlrjP0
AWgPMszM1Omaw==
X-Clacks-Overhead: "GNU Terry Pratchett"
X-CM-Score: 0.00
X-CNFS-Analysis: v=2.4 cv=DfIEF9hW c=1 sm=1 tr=0 ts=62715c55
a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17
a=IkcTkHD0fZMA:10 a=2uTC9AMXqiXzH44MlC4A:9 a=QEXdDO2ut3YA:10
X-AUTH: mrabarnett@:2500
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.8.1
Content-Language: en-GB
In-Reply-To: <8cd15ae0-e6d9-478c-a4be-c354d221b07dn@googlegroups.com>
X-CMAE-Envelope: MS4xfOBIBUGR5UMgwiEtcFD447BCAHie4MJJL5TCPdyIPoDv+yMe5SvE36WEwFiNqbSbLe2y3vk6YdY2/3jxSP8WSeLSsqGiQYng7p3Qetgov4zcFtWpwQyO
pEenS39Em3Ce23ZDEoa/D+j30QPS75JtwtYrtL6mYZstM7Tt1k3SAh3tDTvugOYdFEujylFSLxovCOsXGr9uLA3TaByt5gFhLkQ=
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <aa86d087-55de-7df8-80d9-cc8575919489@mrabarnett.plus.com>
X-Mailman-Original-References: <8cd15ae0-e6d9-478c-a4be-c354d221b07dn@googlegroups.com>
 by: MRAB - Tue, 3 May 2022 16:46 UTC

On 2022-05-03 10:31, Nicolas Formichella wrote:
> 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?
>
Use 'QueryValue' with an empty string:

value = winreg.QueryValue(key, "")

or None:

value = winreg.QueryValue(key, None)

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor