今天因为学校机房问题,想自动化安装vim,不料在编bat的时候不熟练,搞了很久。
坑点1.%path%访问到的是用户的path,而不是系统的path。所以增加环境变量的时候只能增加用户的path。我就是因为增加了系统的path,弄了N个小时。
坑点2:修改完环境变量后,必须进入GUI配置环境变量的地方,这样它才会更新。不然不会更新!!我就是没有注意到这一点,调试的时候莫名其妙。
wmic ENVIRONMENT create name="curdisk",username="%computername%\%username%",VariableValue="C:" wmic ENVIRONMENT create name="vimpath",username="%computername%\%username%",VariableValue="C:Program Files (x86)Vim" wmic ENVIRONMENT create name="devcpppath",username="%computername%\%username%",VariableValue="C:Program Files (x86)Dev-Cpp" echo 请打开一遍环境变量~ pause wmic ENVIRONMENT where "name='Path' and UserName='%computername%\%username%'" set VariableValue="%path%%devcpppath%MinGW64in;%vimpath%Vim80;%vimpath%;%devcpppath%MinGW64x86_64-w64-mingw32in;" echo 请打开一遍环境变量,然后删掉多余的项~ wmic ENVIRONMENT create name="LIBRARY_PATH",username="%computername%\%username%",VariableValue="%devcpppath%MinGW64lib32;%devcpppath%MinGW64x86_64-w64-mingw32lib32;" wmic ENVIRONMENT create name="C_INCLUDE_PATH",username="%computername%\%username%",VariableValue="%devcpppath%MinGW64include;%devcpppath%MinGW64x86_64-w64-mingw32include;%devcpppath%MinGW64libgccx86_64-w64-mingw324.8.1include;" wmic ENVIRONMENT create name="CPLUS_INCLUDE_PATH",username="%computername%\%username%",VariableValue="%devcpppath%MinGW64include;%devcpppath%MinGW64x86_64-w64-mingw32include;%devcpppath%MinGW64libgccx86_64-w64-mingw324.8.1include;%devcpppath%MinGW64libgccx86_64-w64-mingw324.8.1includec++;" pause