- @echo off
- @set Path_=F:\phpStudy\MySQL\bin
- for,/f,"skip=4 tokens=1,2,*",%%a,in,('reg query "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment" /v Path'),do,(
- @set PathAll_=%%c
- )
- echo %PathAll_%|find /i "%Path_%" && set IsNull=true|| set IsNull=false
- if not %IsNull%==true (
- reg add "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment" /v Path /t REG_EXPAND_SZ /d "%PathAll_%;%Path_%" /f
- )
- pause
复制代码 上述代码在添加环境变量时候:直接删除原有数据后再添加
需求:
修改成,直接在原有数据前添加新变量。 |