如果你搜索本问题,多半会来到StackOverflow中看到这个回答
setx /M PATH "%PATH%;<your-new-path>"
Note: CMD中执行
正如该回答的某个回复提到的:
DO NOT USE THIS. setx will truncate PATH to 1024 characters. If PATH was changed before by being prepended with more directories, you will lose most of the original PATH contents!
这个会有1024个字符限制,如果你原有的%PATH%很长会被自动截断。
所以还是老实地调用.NET Framework的方法吧
$newPath = 'F:\common tools\git\bin;F:\common tools\python\app;F:\common tools\python\app\scripts;F:\common tools\ruby\bin;F:\masm32\bin;F:\Borland\BCC55\Bin'
$oldPath = [Environment]::GetEnvironmentVariable('PATH', 'Machine');
[Environment]::SetEnvironmentVariable('PATH', "$newPath;$oldPath",'Machine');
标签:bin,newPath,环境变量,修改,common,PATH,tools,PowerShell From: https://www.cnblogs.com/talentzemin/p/16865710.htmlNote: PowerShell中执行