How to update system PATH variable permanently fro

2019-04-18 06:55发布

We can use setx as discussed here.

setx PATH "%PATH%;C:\Something\bin"

But this command can just make changed to user PATH variable not the system one.

How can we make a similar system wide command?

enter image description here

标签: windows path cmd
2条回答
倾城 Initia
2楼-- · 2019-04-18 07:22

From powershell

setx /M PATH "$($env:path);c:\program files\mynewprogram"
查看更多
戒情不戒烟
3楼-- · 2019-04-18 07:28

Type setx /? to get basic command help. You'll easily discover:

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

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.

查看更多
登录 后发表回答