从Windows批处理文件设置一个系统环境变量? [英] Setting a system environment variable from a Windows batch file?

查看:238
本文介绍了从Windows批处理文件设置一个系统环境变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能在Windows 7中设置在系统级环境变量从命令提示符(甚至XP为此事)。我从提升的命令提示符下运行。

Is it possible to set a environment variable at the system level from a command prompt in Windows 7 (or even XP for that matter). I am running from an elevated command prompt.

当我使用设置命令(设置为name = value ),环境变量似乎是唯一有效在命令提示符的会话。

When I use the set command (set name=value), the environment variable seems to be only valid for the session of the command prompt.

推荐答案

在XP支持工具(可从您的XP光盘安装)配备了一项名为 setx.exe

The XP Support Tools (which can be installed from your XP CD) come with a program called setx.exe:

C:\Program Files\Support Tools>setx /?

SETX: This program is used to set values in the environment
of the machine or currently logged on user using one of three modes.

1) Command Line Mode: setx variable value [-m]
   Optional Switches:
    -m  Set value in the Machine environment. Default is User.

...
For more information and example use: SETX -i

我认为Windows 7的居然附带了 SETX 作为标准安装的一部分。

I think Windows 7 actually comes with setx as part of a standard install.

这篇关于从Windows批处理文件设置一个系统环境变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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