关于PATH(on Windows)

1.使用batch file设置PATH

setx PATH "%cd%;%path%;"
pause

2.用户PATH和系统PATH

Windows实际上是将系统PATH和用户PATH进行合并,使用echo %path%可查看到合并后的结果。

有时会出现这样的问题,虽然将可执行文件的目录添加到了用户PATH中,可是在CLI中运行时却说找不到命令,这是怎么回事呢?

实际上对系统PATH有字符串长度限制,当系统PATH超过某一长度时,用户PATH将不再合并到系统PATH中,所以找不到命令。

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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容