I've been working on the script for a couple days now, and for some reason I am struggling with my my code to work properly. When I run the python code the program is suppose to add a value to a key in the windows registry; however, that doesn't happen in there. I ended up looping the values to see if its on python side and the program spits out my values I've placed so I'm not sure.
Output:
('notepad', 'notepad.exe', 1)
('PythonTestFile', 'explorer', 1)
('testpurpose', '1', 1)
('notepad.exe', 'notepad.exe', 1)
CODE
import winreg
#connecting to key in registry
access_registry = winreg.ConnectRegistry(None,winreg.HKEY_CURRENT_USER)
access_key = winreg.OpenKey(access_registry, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\DisallowRun", 0, winreg.KEY_ALL_ACCESS | winreg.KEY_WOW64_64KEY)
#accessing the key to open the registry directories under
for n in range(20):
try:
x = winreg.EnumKey(access_key,n)
print(x)
except:
break
try:
winreg.SetValueEx(access_key, "testpurpose", 0, winreg.REG_SZ, "1")
winreg.CloseKey(access_key)
except Exception as e:
print(e)
I've tried multiple videos and looked through the documentation, but I'm not sure where I'm going wrong. I even switched between the 64x and 32x with the permissions and tried restarting my computer multiple times, and nothing seems to work. The only thing I can think of is it has the wrong path. If you could help that would be awesome!