Windows 7 environment variable not working in path


I am trying to set up some path using environment variable. I added an environment variable "MAVEN_HOME" with the value "C:\maven". Then in the path I added "%MAVEN_HOME%\bin;". When I type "echo $MAVEN_HOME%" I get the correct "C:\maven" printed on the screen. But when I type "mvn" which is a batch file in the "bin" directory, it can't find it.

So, I manually added the entire path in PATH. "C:\maven\bin;" and it was able to find "mvn" and execute it.

Could someone help me what I did wrong?

This question is tagged with variables windows-7 path environment

~ Asked on 2011-12-31 01:40:57

The Best Answer is


I had exactly the same problem, to solve it, you can do one of two things:

  • Put all variables in System Variables instead of User and add the ones you want to PATH


  • Put all variables in User Variables, and create or edit the PATH variables in User Variable, not In System. The Path variables in System don't expand the User Variables.

If the above are all correct, but the problem is still present, you need to check the system Registry, in HKEY_CURRENT_USER\Environment, to make sure the "PATH" key type is REG_EXPAND_SZ (not REG_SZ).

~ Answered on 2012-11-25 22:53:23


Check if there is a space character between the previous path and the next:

Incorrect: c:\path1; c:\Maven\bin\; c:\path2\

Correct: c:\path1;c:\Maven\bin\;c:\path2\

~ Answered on 2012-10-23 12:44:55

Most Viewed Questions: