On 2/2/21, Christopher Barker <python...@gmail.com> wrote: > > In the common case, folks have their environment variables set in an > initialization file (or the registry? I've lost track of what Windows does > these days)
It hasn't fundamentally changed since the mid 1990s. Configurable system variables are set in the regsitry key "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment", and configurable user variables are set in "HKCU\Environment". A process is spawned with an environment that's sourced from the parent process. Either it's inherited from the parent's environment or it's a new environment that was passed to CreateProcessW(). The ancestor of most interactive processes in a desktop session is the graphical shell, Explorer. At startup, it calls an undocumented shell32 function (RegenerateUserEnvironment) to load a new environment from scratch. It also reloads its environment in response to a WM_SETTINGCHANGE "Environment" message. The documented way to reload the environment from scratch is CreateEnvironmentBlock(&env, htoken, FALSE) and SetEnvironmentStringsW(env). _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/ZKIGW3CIM7GGRAVTXL2V44XZ4Q7GXG7Q/ Code of Conduct: http://python.org/psf/codeofconduct/