Python で次のレジストリ スクリプトをエミュレートしようとしています。
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell\Open with notepad]
[HKEY_CLASSES_ROOT\*\shell\Open with notepad\command]
@="notepad %1"
私の試みは次のようになります。
import winreg as wreg
reg = wreg.ConnectRegistry(None, wreg.HKEY_CLASSES_ROOT)
root = wreg.OpenKey(reg, r'\*\shell', 0, wreg.KEY_ALL_ACCESS)
key = wreg.CreateKey(root, r'Open with notepad')
wreg.SetValue(key, None, wreg.REG_SZ, '')
wreg.FlushKey(key)
key2 = wreg.CreateKey(root, r'Open with notepad\command')
wreg.SetValue(key2, None, wreg.REG_SZ, 'notepad %1')
wreg.FlushKey(key2)
root.Close()
key.Close()
key2.Close()
しかし、それは何もしないようです。エラーは表示されませんが、regedit によるとキーはレジストリに追加されません。
私は何を間違っていますか?