Setting Windows System Path In Registry Via Python Winreg
I've written a program to add directories to the PATH variable via the registry, either the HKCU(user) or HKLM(system) path, depending on an input option. It works fine when using
Solution 1:
As in the comments, changing REG_SZ
to REG_EXPAND_SZ
did the trick, as variables using "%" weren't being recognized. This also works when no "%"s exist, so I use it for the user path as well rather than needing to switch between the two.
registry.SetValueEx(env_key,"Path",0,registry.REG_EXPAND_SZ,val_string)
Post a Comment for "Setting Windows System Path In Registry Via Python Winreg"