Board logo

标题: 关于环境变量的问题 请教高手 [打印本页]

作者: xiaomaer     时间: 2006-9-1 10:58    标题: 关于环境变量的问题 请教高手

有一程序,每次使用时要修改"PATH"环境变量,并且增加几个用户的环境变量和几个系统的环境变量才能运行,现在想写个小脚本来轻松完成这一步骤,曾经想过用DOS的批处理命令,但是DOS对环境变量的设置是临时的.也想过修改AUTOEXEC.BAT,但是这个文件在XP下就没用了,而且因为可能的客户对计算机不是很了解,希望达到的效果是只运行一个脚本就完成,请问有什么办法能够实现? 或者有什么办法能够让DOS里设置的环境变量永久有效? 谢谢!
还想过用批处理文件通过修改注册表写环境变量,因为修改的内容都是固定的,有没有什么办法不用人工每次都EDIT,而是直接在批处理里用命令完成呢?
作者: a9319751     时间: 2006-9-12 13:39
setx对你有用
作者: a9319751     时间: 2006-9-14 03:20
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