Apr-25-2017, 07:24 PM
Hi,
Having some trouble with a project. Using Python 2.7 and 3.5 (trying to keep things compatible with both for simplicity). Using 3.5 for most of my first-pass testing/dev.
I'm trying to set an environment variable in the user's profile on Windows. Currently running Win 10, but have seen the same behavior on 8.1.
I can set the environment variable via registry key (winreg.SetValueEx) and send the system broadcast needed to have future processes pick up the change. But what I'm trying to do now is set the environment for the current process so I can spawn a child that will inherit the new setting.
Any help is appreciated, and thank you.
Brian
Having some trouble with a project. Using Python 2.7 and 3.5 (trying to keep things compatible with both for simplicity). Using 3.5 for most of my first-pass testing/dev.
I'm trying to set an environment variable in the user's profile on Windows. Currently running Win 10, but have seen the same behavior on 8.1.
I can set the environment variable via registry key (winreg.SetValueEx) and send the system broadcast needed to have future processes pick up the change. But what I'm trying to do now is set the environment for the current process so I can spawn a child that will inherit the new setting.
os.environ["FOO"] = valuedoesn't seem to be setting the current process' environment properly, running "set" after the script completes doesn't show the variable set in the current process. I can't seem to find much beyond "it should work". Is there another, more effective, way to set the environment variables for the current process? My reading of putenv() is that it wouldn't work to set the value here, is that correct?
Any help is appreciated, and thank you.
Brian