Windows 7环境变量在路径中不起作用 [英] Windows 7 environment variable not working in path

查看:159
本文介绍了Windows 7环境变量在路径中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用环境变量设置一些路径. 我添加了一个值为"C:\ maven"的环境变量"MAVEN_HOME". 然后在路径中添加了%MAVEN_HOME%\ bin; ... rest". 当我键入"echo $ MAVEN_HOME%"时,我会在屏幕上打印正确的"C:\ maven". 但是,当我在"bin"目录中键入一个批处理文件"mvn"时,找不到它.

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;...rest". 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.

因此,我手动将整个路径添加到PATH中. "C:\ maven \ bin; ...休息" 并且能够找到并执行"mvn".

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

有人可以帮我做错什么吗?

Could someone help me what I did wrong?

推荐答案

我有完全相同的问题,要解决此问题,您可以执行以下两项操作之一:

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

  • 将所有变量(而不是用户)放入系统变量",然后将要添加的变量添加到PATH

  • 将所有变量放在用户变量"中,然后在用户变量"而不是系统"中创建或编辑PATH变量.系统中的路径变量不会扩展用户变量.

如果以上各项均正确,但问题仍然存在,则需要检查系统注册表,位于HKEY_CURRENT_USER \ Environment中,以确保"PATH"键类型为REG_EXPAND_SZ(而非REG_SZ).

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).

这篇关于Windows 7环境变量在路径中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆