如何从cmd永久更新系统PATH变量? [英] How to update system PATH variable permanently from cmd?

查看:220
本文介绍了如何从cmd永久更新系统PATH变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们可以使用setx,如此处所述.

We can use setx as discussed here.

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

但是此命令只能将用户PATH变量更改为系统变量.

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

我们如何发出类似的系统范围命令?

How can we make a similar system wide command?

推荐答案

键入setx /?以获得基本的命令帮助.您将轻松发现:

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.

您需要从提升的命令提示符下运行此命令.右键单击cmd快捷方式,然后选择Run as Administrator.

You need to run this from an elevated command prompt. Right-click the cmd shortcut and select Run as Administrator.

例如

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

警告:

我们可能会破坏当前系统的PATH变量.修改之前,请确保已备份其值.

We may destroy the current system's PATH variable. Make sure you backup its value before you modify it.

这篇关于如何从cmd永久更新系统PATH变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆