- globally-accessible environment variables
- Posted by pete on April 7th, 2008
Hi folks --
1. There must be a better way to set accessible-by-all-processes
environment variables than by writing the Registry, but that's what it
looks like (from VS2005 online docs) I have to do. Any other ideas
about writing these environment variables? I'd be grateful to hear
them.
2. Absent any new ideas, I'm writing environment variables into the
Registry at
HKLM\SYSTEM\ CurrentControlSet \Control\Session Manager
\Environment
which of course works just dandy for the current (i.e., my) process.
But later _getenv( ) calls by other processes retrieve that
environment variable not from where I wrote it (which I imagined,
without any real knowledge, was the right place) but from:
HKLM\SYSTEM\ ControlSet011 \Control\Session Manager\Environment
What is ControlSet011? Can I depend on it to always hold the variables
I need to save? I thought it was somewhat volatile or capriciously
renamable.
Thanks, everyone.
-- Pete
- Posted by Sebastian G. on April 7th, 2008
pete wrote:
setx.exe does it the same way, though it seems to be wrong. sysdm.cpl uses
the Get/Write(Private)Profile* functions, dunno if they also broadcast the
changes or how it does manually.
And is badly wrong, since it requires admin rights, and is easily trumped by
all overwrites due to the same subkey in HKCU (that is, if the user has
redefined the variable as per-user variable).
It's the current ControlSet subkey. CurrentControlSet is just a reparse
point that links to the actual ControlSet subkey, and simply changing this
link allows Windows to easily start with alternate configurations (like Safe
Mode or Last Known Good).
It is, that's why one should use the CurrentControlSet link instead, which
always resolve to the subkey you want.
- Posted by Christian ASTOR on April 7th, 2008
On 7 avr, 19:17, pete <pete...@yahoo.com> wrote:
KB104011