Python Forum
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to add new registry key
#3
After checking the link I got from Metulburr I came up to following code but still failed on

ValueError: Could not convert the data to the specified type.

import winreg as wreg

def newregkey():
    key = wreg.CreateKey(wreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\system")
    wreg.SetValue(key, 'NewSubkey', wreg.REG_SZ, 'LocalAccountTokenFilterPolicy')
    wreg.SetValueEx(key, 'ValueName', 0, wreg.REG_DWORD, '0x00000001')
    key.Close()
can any one tell me what is wrong

Traceback:
File "C:\Program Files\Python36\lib\tkinter\__init__.py", line 1702, in __call__
return self.func(*args)
File "C:\page\Backup\LandaUtilitiesInstallar.py", line 407, in <lambda>
self.InstallButtom.bind('<Button-1>',lambda e:LandaUtilitiesInstallar_support.install_lclick(e))
File "C:\page\Backup\LandaUtilitiesInstallar_support.py", line 113, in install_lclick
newregkey()
File "C:\page\Backup\LandaUtilitiesInstallar_support.py", line 70, in newregkey
wreg.SetValueEx(key, 'ValueName', 0, wreg.REG_DWORD, '0x00000001')
ValueError: Could not convert the data to the specified type.
Reply


Messages In This Thread
How to add new registry key - by shlomi27 - Aug-11-2018, 07:52 PM
RE: How to add new registry key - by metulburr - Aug-11-2018, 08:19 PM
RE: How to add new registry key - by shlomi27 - Aug-15-2018, 07:23 AM
RE: How to add new registry key - by reidnax - Feb-04-2021, 05:45 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question How to add Python folder in Windows Registry ? Touktouk 1 311 Feb-20-2024, 01:04 PM
Last Post: DeaD_EyE
  Read complete windows registry? fredep57 3 975 Mar-15-2023, 08:14 PM
Last Post: buran
  Automatic registering python to registry kozaizsvemira 1 2,225 Oct-22-2019, 11:23 AM
Last Post: kozaizsvemira
  How to ignore - ERROR: The system was unable to find the specified registry key or va asheru93 9 6,724 Feb-04-2019, 06:35 AM
Last Post: asheru93
  Registry Key Access malonn 11 9,461 Jul-26-2018, 09:45 AM
Last Post: gontajones
  Looking for advice about "registry" implementation voltron 0 2,325 Feb-06-2018, 07:26 AM
Last Post: voltron
  Python 3.x Windows 7 registry file associations broken pixhellmann 2 5,095 Sep-12-2017, 09:14 PM
Last Post: Larz60+
  [WinReg]>Issue when reading a registry key CSA75 4 8,980 Mar-28-2017, 03:35 PM
Last Post: CSA75

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020