Posted on 2009-12-31 16:35
S.l.e!ep.¢% 阅读(533)
评论(0) 编辑 收藏 引用 所属分类:
DOS
@echo off&setlocal enabledelayedexpansion
:begin
cls
set/p path_=请输入你要添加的环境变量的路径:
if not defined path_ goto error
for,/f,"skip=4 tokens=1,2,*",%%a,in,('reg query "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment" /v Path'),do,(
echo 当前的环境变量为:
echo %%c
echo;
set/p yesno=是否确认将"%path_%"添加到系统环境变量中去?[Y]/[N]
if /i "!yesno!"=="y" (
reg add "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment" /v Path /t REG_EXPAND_SZ /d "%%c;%path_%" /f
)
goto :eof
)
pause
goto :Eof
:error
echo 输入错误,请重新输入
pause
goto begin