今天因为学校机房问题,想自动化安装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%\MinGW64\bin;%vimpath%\Vim80;%vimpath%;%devcpppath%\MinGW64\x86_64-w64-mingw32\bin;" echo 请打开一遍环境变量,然后删掉多余的项~ wmic ENVIRONMENT create name="LIBRARY_PATH",username="%computername%\\%username%",VariableValue="%devcpppath%\MinGW64\lib32;%devcpppath%\MinGW64\x86_64-w64-mingw32\lib32;" wmic ENVIRONMENT create name="C_INCLUDE_PATH",username="%computername%\\%username%",VariableValue="%devcpppath%\MinGW64\include;%devcpppath%\MinGW64\x86_64-w64-mingw32\include;%devcpppath%\MinGW64\lib\gcc\x86_64-w64-mingw32\4.8.1\include;" wmic ENVIRONMENT create name="CPLUS_INCLUDE_PATH",username="%computername%\\%username%",VariableValue="%devcpppath%\MinGW64\include;%devcpppath%\MinGW64\x86_64-w64-mingw32\include;%devcpppath%\MinGW64\lib\gcc\x86_64-w64-mingw32\4.8.1\include;%devcpppath%\MinGW64\lib\gcc\x86_64-w64-mingw32\4.8.1\include\c++;" pause