Forum Discussion
Environment Variable inconsistency
We utilize the ClientName variable in our production environment, but we've had some inconsistent results in it's behavior.
From what I understand, when using remoting technology such as RDP, windows creates a value in HKCU\Volatile Environment\<session ID> called 'CLIENTNAME' with the value being the remote device's computer name. Then, when software is launched, it reads from HKCU\Volatile Environment, HKCU\Environment, and HKLM\System\CurrentControlSet\Control\Session Manager\Environment.
Herein lies my dilemma. Occasionally, when our users log into their sessions (we utilize Omnissa Horizon VDI, using Horizon Blast) for the day, some of them (roughly 1-2%) will not have the Environment variable set for CLIENTNAME. This is validated by the 'set' command being ran in command prompt, with the results not showing the CLIENTNAME variable shown at all. When I check the registry, the value exists and is populated with the client device name. I then re-launch CMD and run the command again, to validate it is not a timing issue, and it still does not show.
Then I restart explorer.exe using task manager. Once I do this, and re-launch CMD again, it shows when I run the set command. I could see maybe explorer caches some variables and it's referenced from there, but that thought falls apart when I continue testing.
Once the variable is set and explorer is relaunched, I can make any changes to the registry key/value and it will reflect upon re-launching CMD, as expected.
There are other variables in HKCU\Volatile Environment\<session ID> that also do not populate until explorer.exe is restarted.
Is this a bug or am I misunderstanding how windows handles environment variables?
Thank you.