windows 系统与用户 PATH 环境变量...只有当我将路径添加到用户 PATH 时,winmerge 才有效
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21270267/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
System versus user PATH environmental variable...winmerge works only if I add the path to the user PATH
提问by Millemila
If I add C:\Program Files (x86)\WinMerge
to the User PATH
variable(by right click on computer -> advanced system settings -> environmental variables), once I open a new cmd shell WinmergeU.exe is not recognized. If I add that path to the System PATH
variable, WinmergeU.exe is correctly recognized instead. I though there was no difference between User and System, beside the fact that if I set it on System all the users will see it, while the User PATH
is local. Am I doing something wrong?
如果我添加C:\Program Files (x86)\WinMerge
到用户PATH
变量(通过右键单击计算机 -> 高级系统设置 -> 环境变量),一旦我打开一个新的 cmd shell WinmergeU.exe 就无法识别。如果我将该路径添加到 SystemPATH
变量,则会正确识别 WinmergeU.exe。我虽然用户和系统之间没有区别,但如果我在系统上设置它,所有用户都会看到它,而用户PATH
是本地的。难道我做错了什么?
EDIT 1:
编辑 1:
In the follow you can see first the case in which C:\Program Files (x86)\WinMerge
is added to the System PATH
variable (but not to the User), then when it is added to the User PATH
variable (but not to the System). In the first case Winmerge window launch correctly (not shown) and as you can see the path is shown by the echo %PATH% command. In the second case it does not launch and the path it is not shown by echo %PATH%. (note that I clearly confirmed with OK and closed the environmental variable windows before taking these screenshots, and I opened a new cmd right after changing PATH and pressing ok). This issue might be related to my question here (Does echo %PATH% expand to only the system or also the user variables?) but since it might not be I posted two different question.
在下面,您可以首先看到C:\Program Files (x86)\WinMerge
添加到系统PATH
变量(但不添加到用户)的情况,然后是添加到用户PATH
变量(但不添加到系统)的情况。在第一种情况下,Winmerge 窗口正确启动(未显示),正如您所看到的,echo %PATH% 命令显示了路径。在第二种情况下,它不会启动,并且它的路径也没有由 echo %PATH% 显示。(请注意,在截取这些屏幕截图之前,我清楚地确认了 OK 并关闭了环境变量窗口,并且在更改 PATH 并按 OK 后立即打开了一个新的 cmd)。这个问题可能与我在这里的问题有关(echo %PATH% 是否仅扩展到系统或用户变量?)但因为它可能不是我发布了两个不同的问题。
回答by David Heffernan
You must be getting something wrong, or have environmental problems with your machine. Adding a user PATH
environment variable does result in it being merged into the environment of a new process.
你一定是出了什么问题,或者你的机器有环境问题。添加用户PATH
环境变量确实会导致它被合并到新进程的环境中。
Update:Perhaps this comment from the MSDN topic on environment variablesmight be pertinent:
更新:也许MSDN 主题中关于环境变量的评论可能是相关的:
Found out that on Windows Server 2003, once the system PATH passes 1920 characters, the user PATH environment variable is no longer merged with it to set the process PATH environment variable, even though the full system PATH (even if larger) will be included in the process PATH variable.
发现在 Windows Server 2003 上,一旦系统 PATH 超过 1920 个字符,用户 PATH 环境变量不再与其合并以设置进程 PATH 环境变量,即使完整的系统 PATH(即使更大)也会包含在进程 PATH 变量。
回答by coredump
On Windows 7, also make sure that the system path does not end with a backslash. If it does, the USER PATH is appended to the system path as per usual, but after a line break, which breaks things. In the latter case, the simple command "path" and "echo %PATH% " will print 2 different outputs.
在 Windows 7 上,还要确保系统路径不以反斜杠结尾。如果是这样,则 USER PATH 会像往常一样附加到系统路径,但在换行符之后会中断。在后一种情况下,简单的命令 "path" 和 "echo %PATH% " 将打印 2 个不同的输出。
回答by krspahr
For 16.6, I've confirmed this issue to be a path length issue as well. At a cmd prompt, typing 'set', you can see all of the env. variables. The user path cadence variables and others weren't included. I saved the original complete path text, then I went through and trimmed specific (system) path elements that were deemed unnecessary. after this, in a new cmd session, typing 'set' now shows the user path elements tacked on to the end of the system path elements, because they now fit.
对于 16.6,我已确认此问题也是路径长度问题。在 cmd 提示符下,输入“set”,您可以看到所有的 env。变量。不包括用户路径节奏变量和其他变量。我保存了原始的完整路径文本,然后我浏览并修剪了被认为不必要的特定(系统)路径元素。此后,在新的 cmd 会话中,现在输入“set”将显示附加到系统路径元素末尾的用户路径元素,因为它们现在适合。