在此处最佳答案的最高投票评论 (How to persistently set a variable in Windows 7 from a batch file?) 中提到 %PATH% 扩展到系统加上用户变量。真的吗?在我的笔记本电脑中,如果我打开 cmd 并输入数字
echo %PATH%
我只看到系统变量。谁能澄清这一点?
干杯 A.
最佳答案
默认情况下,为新进程提供的环境合并了系统变量和用户变量。因此,如果您为系统和用户定义了一个 PATH
变量,那么这两个值将合并。
您的实验似乎与我上面的陈述相矛盾。但是,当我重复您的实验时,我可以看到系统和用户设置的值合并了。所以我只能得出结论,您没有正确执行实验。
更新:也许这个comment from the MSDN topic on environment variables可能是相关的:
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 - echo %PATH% 是否仅扩展到系统变量或用户变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21269171/