Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:

Path=%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\Wbem;%SYSTEMROOT\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft Windows Performance Toolkit\

...whereas %PATH% for cmd.exe run as Administrator is as follows:

Path=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\Wbem;%SYSTEMROOT\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft Windows Performance Toolkit\

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?

share|improve this question
up vote 6 down vote accepted

Two things I might try.

  1. Run an sfc /scannow to see if that fixes any larger issues at play.
  2. Check the registry for the Path key in HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment. What's the type. It should say REG_EXPAND_SZ
share|improve this answer
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 Vigneau Aug 15 '11 at 18:27
@Steve - Sweet! I even learned something about that :) – Nixphoe Aug 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! – Adrián Pérez Aug 20 '14 at 15:59

I ran into the same issue while trying to configure Maven...

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.