Environment variables not used, even after reboot

0

I modified some environment variables (using both setx and through the GUI: Control Panel--System Properties--Advanced--Environment Variable). The changes persist after rebooting, which I can see in the terminals, in regedit or through the GUI. But they are not picked up by powershell, cmd or gitbash. Why would that be?

Here's some excerpts from powershell using the example environment variable %HOMEDRIVE%, run immediately after rebooting:

PS H:\> Get-ItemProperty Registry::HKEY_CURRENT_USER\Environment\


AWP_LOCALE182      : en-us
HOMEDRIVE          : C:
...

PS H:\> Get-ItemProperty "Registry::HKLM\System\CurrentControlSet\Control\Session Manager\Environment"

...
HOMEDRIVE              : C:
...

PS H:\> $Env:HOMEDRIVE
H:

cmd is very similar, except that the scripts in the two answers here do successfully update the environment variables in cmd, but not for powershell or gitbash.

I have administrator privileges, but it is a work machine, so some restrictions still apply.

craq

Posted 2019-01-29T02:13:40.483

Reputation: 101

1%homedrive% is a special environment variable that reflects the current user’s homedrive as specified in Active Directory. You can’t change that. If you’re trying to set a variable, use a different name. – Appleoddity – 2019-01-29T05:13:42.337

When I open powershell, cmd or gitbash, they start in %HOMEDRIVE%%HOMEPATH%. At the moment it is a location that I never use, so my first command is always cd somewhere_useful. I have never used Active Directory before - does that mean it's a setting that is managed by my network admins? – craq – 2019-01-29T20:40:16.100

Yes. This is normal behavior. – Appleoddity – 2019-01-29T22:38:08.580

No answers