windows 如何从cmd永久更新系统PATH变量?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24219627/
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
How to update system PATH variable permanently from cmd?
提问by Nam G VU
回答by Hans Passant
Type setx /?
to get basic command help. You'll easily discover:
键入setx /?
以获取基本命令帮助。你会很容易发现:
/M Specifies that the variable should be set in
the system wide (HKEY_LOCAL_MACHINE)
environment. The default is to set the
variable under the HKEY_CURRENT_USER
environment.
You need to run this from an elevated command prompt. Right-click the cmd
shortcut and select Run as Administrator
.
您需要从提升的命令提示符运行它。右键单击cmd
快捷方式并选择Run as Administrator
。
E.g.
例如
setx /M PATH "%PATH%;C:\Something\bin"
Caution:
警告:
We may destroy the current system's PATH variable. Make sure you backup its value before you modify it.
我们可能会破坏当前系统的 PATH 变量。请确保在修改之前备份其值。
回答by Nathan Julsrud
From powershell
来自 PowerShell
setx /M PATH "$($env:path);c:\program files\mynewprogram"