中国DOS联盟论坛

中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --
联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
游客 | 登录 | 注册 | 会员 | 搜索 | 中国DOS联盟
中国DOS联盟论坛
现在时间是 2026-08-02 01:26
48,037 主题排行 / 350,122 发帖 / 今日 2 篇 / 48,250 会员排行
DOS批处理 & 脚本技术(批处理室) » 关于环境变量的问题 请教高手
可打印版本  1,132 / 2
第1楼 xiaomaer 发表于 2006-09-01 10:58
新手上路 发帖 2 积分 8
关于环境变量的问题 请教高手
有一程序,每次使用时要修改"PATH"环境变量,并且增加几个用户的环境变量和几个系统的环境变量才能运行,现在想写个小脚本来轻松完成这一步骤,曾经想过用DOS的批处理命令,但是DOS对环境变量的设置是临时的.也想过修改AUTOEXEC.BAT,但是这个文件在XP下就没用了,而且因为可能的客户对计算机不是很了解,希望达到的效果是只运行一个脚本就完成,请问有什么办法能够实现? 或者有什么办法能够让DOS里设置的环境变量永久有效? 谢谢!
还想过用批处理文件通过修改注册表写环境变量,因为修改的内容都是固定的,有没有什么办法不用人工每次都EDIT,而是直接在批处理里用命令完成呢?
第2楼 a9319751 发表于 2006-09-12 13:39
中级用户 发帖 170 积分 439
setx对你有用
第3楼 a9319751 发表于 2006-09-14 03:20
中级用户 发帖 170 积分 439
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.

2) Registry Mode: setx variable -k hive\key\...\value
Optional Switches:
-m Set value in the Machine environment. Default is User.

3) File Mode: setx variable -f file {-a x,y | -r x,y "string"} [-d d] [-x] [-m]
Required Switches:
-f file : Specify file name to use.
-a x,y : Specify absolute coordinates and offset.
-r x,y "string" : Specify coordinates and offset relative to string.
Optional Switches
-d ,:\ etc. : Specify additional delimiters.
-x : Displays file coordinates. Switches -a -r -e ignored!!
-m : Set value in the Machine environment. Default is User.

For more information and example use: SETX -i
[ 联系联盟系统管理团队 - 中国DOS联盟 - 标准版 ]
Sponsored by ifanr Inc | © 2001–2023