Page 1 of 1

[SOLVED]: Syntax for creating an empty registry key

Published: April 8, 2024 - 1:49 PM
by croquebert
Context:
WAPT version: 2.2.3 Enterprise
Server OS: Debian 12
OS administration console: Win10pro
OS package dev station: Win10pro

Good morning,,

I want to create an empty registry key (containing no value other than the default one) as created by the standard registry editor.

If I use the syntax:

Code: Select all

registry_set(HKEY_LOCAL_MACHINE,r'SOFTWARE\WOW6432Node\CLETEST', None, None)
This does create a CLETEST registry key, but it also creates a value containing no data named None (of type REG_SZ) inside the CLETEST key, which results in the following via a registry export:

Code: Select all

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\CLETEST]
"None"=""
Whereas, via the classic registry utility, a creation results in:

Code: Select all

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\CLETEST]
Thanks in advance.

CR

Re: Syntax for creating an empty registry key

Published: April 8, 2024 - 2:52 PM
by dcardon
Hi Christophe,

I'm not sure if the necessary components are in the setuphelpers, but you can try with winreg:

Code: Select all

import winreg
from setuphelpers import *
winreg.CreateKey(HKEY_LOCAL_MACHINE,r'SOFTWARE\WOW6432Node\CLETEST')
Sincerely,
Denis

Re: Syntax for creating an empty registry key

Published: April 8, 2024 - 4:14 PM
by croquebert
Hi Denis,

Thanks for the feedback.

Your method does indeed work.
I wasn't sure I'd read the setuphelpers documentation correctly, hence my question.

For now, I'm still using setuphelpers, but I'm removing the "None" value immediately afterward.

If I ever need to create only what's necessary (because there might be something like Inotify on registry hive elements), then I'll use the winreg import.

We can consider the issue resolved, thanks.

Christophe.

Re: [SOLVED]: Syntax for creating an empty registry key

Published: April 8, 2024 - 5:09 PM
by dcardon
Thanks for your feedback, Christophe :-)
Denis