I have a piece of code that creates a registry key and changes value in it. Although it work perfectly fine in my system but it fails when ran on any other system.
keyVal= r'Software\Microsoft\Windows\CurrentVersion\Policies'
key2change= OpenKey(HKEY_CURRENT_USER, keyVal,0,KEY_ALL_ACCESS)
CreateKey(key2change,keyVal+"\System")
key2change= OpenKey(HKEY_CURRENT_USER, keyVal+"\System",0,KEY_ALL_ACCESS)
SetValueEx(key2change, "Wallpaper", 0, REG_SZ, picName)
SetValueEx(key2change, "WallpaperStyle", 0, REG_SZ, "0")
This doesn't create the "System" key in other PC thus no value is changed. Also I am using Windows 7 x64 bit and I am packaging the code using pyinstaller.
This did worked out for me.
keyVal= r'Software\Microsoft\Windows\CurrentVersion\Policies'
key2change= OpenKey(HKEY_CURRENT_USER, keyVal,0,KEY_ALL_ACCESS)
CreateKey(key2change,keyVal+"\System", 0, KEY_ALL_ACCESS)
key2change= OpenKey(HKEY_CURRENT_USER, keyVal+"\System",0,KEY_ALL_ACCESS)
SetValueEx(key2change, "Wallpaper",0,REG_SZ, "D:\\test.jpg")
SetValueEx(key2change, "WallpaperStyle",0,REG_SZ, "2")