简体   繁体   English

设置环境变量窗口

[英]Set Environment Variables Windows

First off, I'd like to apologise if this has already been covered. 首先,如果您已解决此问题,我想道歉。 It's difficult to filter through all the existing issues similar to this one. 很难过滤掉所有与此类似的现有问题。

So in Windows there is two (as far as I'm aware) ways to set environment variables. 因此,在Windows中,有两种(据我所知)设置环境变量的方法。 First one is through the Command Prompt and the second is through System Properties in the Control Panel. 第一个是通过命令提示符,第二个是通过控制面板中的系统属性。

The former would be more desirable for me however I have an issue where the variable only lasts and exists in that session. 前者对我来说更理想,但是我有一个问题,其中变量仅持续存在并且存在于该会话中。 This gets considerably annoying when I have to re-set my Java path every time. 当我每次必须重新设置Java路径时,这会变得很烦人。

The latter is what I have to resort to, it takes time and once in a blue moon I'll forget where to locate the menu. 后者是我必须采取的措施,它需要时间,并且一旦出现在蓝色的月亮中,我会忘记在哪里找到菜单。

Is there something I have to do in the Command Prompt to get it set permanently? 我必须在命令提示符中做些什么才能永久设置它? Possibly a flag or switch to append to the command? 可能是一个标志或附加到命令的开关?

The SETX command can modify environment variables persistently: SETX命令可以持久地修改环境变量:

Setx provides the only command-line or programmatic way to directly and permanently set system environment values. Setx提供直接和永久设置系统环境值的唯一命令行或编程方式。

It's quite a powerful tool but read the notes carefully on that page though because there are a few little catches to using it. 它是一个非常强大的工具,但是请谨慎阅读该页面上的说明,因为使用它会引起一些注意。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM