I have a Windows 7 machine which, when Command Prompt is run by a normal user, fails to expand environment variables in the %PATH%. If command prompt is instead run as administrator (right click, Run as administrator) then %PATH% is appropriately expanded.

Specifically, %PATH% for cmd.exe run as the user (displayed via set path) is as follows:

I tried logging in as a new user to create a new profile, and the issue persists on that profile as well. HKEY_CURRENT_USER\Environment\PATH does not exist, and HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\Path matches the defined system-wide path in Computer Properties -> Environment Variables.

Does anyone have any ideas of what this might be, or where I can look?

That was it. If I take a normal machine and set it to REG_SZ the problem occurs, if I set it back to REG_EXPAND_SZ it gets fixed.
–
Steve VigneauAug 15 '11 at 18:27

@Steve - Sweet! I even learned something about that :)
–
NixphoeAug 15 '11 at 18:31

But I wonder. Why it creates those env vars with the wrong value type in the registry? I don't remember having this problem before, I'm using Windows 8.1 Update 1 and it seems this issue might have happen even in XP! support.microsoft.com/kb/329308
–
Adrián PérezAug 20 '14 at 15:59

I found this post on Superuser that shed some light on the issue, but it didn't work for me. The issue seemed to be about rights elevation, since an admin shell would work, but a user shell wouldn't. I finally decided to just recreate the user variables as system variables instead, and add those to the global path.

This worked for a couple of variables, but I had one pair that still wouldn't expand. I recreated them with new names a couple of times, to no avail. However, the variables finally expanded correctly in the user shell after I disabled UAC, rebooted, re-enabled UAC, and rebooted again.