I am struggling with winreg at the moment.
I want to make with python exactly the same as this code in .reg file:
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOTDirectoryshell©Gerberzipcommand] @="C:gerberzip.exe "%1""
That is to create a key with default name, on the specified path and with the value of the second line.
I have tried this code but I cant make it work and I dont really understand very well why
import winreg REG_PATH = r"Directoryshell©Gerberzipcommand" name = "(Predeterminado)" value = "C:gerberzip2.exe "%1"" winreg.CreateKey(winreg.HKEY_CLASSES_ROOT, REG_PATH) registry_key = winreg.OpenKey(winreg.HKEY_CLASSES_ROOT, REG_PATH, 0, winreg.KEY_WRITE) winreg.SetValueEx(registry_key, name, 0, winreg.REG_SZ, value) winreg.CloseKey(registry_key)
To be honest, one line in a .reg file becomes way too complex on winreg
Source: Python Questions