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

查看:50
本文介绍了从 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.

当我使用 set 命令 (set 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 CD 安装)带有一个名为 setx.exe 的程序:

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

C:Program FilesSupport 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天全站免登陆