1、罕铞泱殳 新建一个文本文件:SetEnvironmentVariable.bat,输入如下脚本代码:rem 作者:exp造婷用痃lorer101rem 请注意用管理员权限运行该批处理文件,否则会出现find命令无法识别的错误@echo offver | find "4.0." > NUL && goto win_xp ver | find "4.10." > NUL && goto win_xp ver | find "4.90." > NUL && goto win_xp ver | find "3.51." > NUL && goto win_xp ver | find "5.0." > NUL && goto win_xp ver | find "5.1." > NUL && goto win_xp ver | find "5.2." > NUL && goto win_xp ver | find "6.0." > NUL && goto win7 ver | find "6.1." > NUL && goto win7 ver | find "6.2." > NUL && goto win8 ver | find "6.3." > NUL && goto win8:win_xprem 设置第三方库环境变量THIRD_PARTYwmic ENVIRONMENT where "name='BOOST_LIB'" deletewmic ENVIRONMENT create name="BOOST_LIB",username="<system>",VariableValue="D:\work\boost"echo %BOOST_LIB%goto end:win7@setx BOOST_LIB "D:\work\boost" -mecho %BOOST_LIB%goto end:win8@setx BOOST_LIB "D:\work\boost" -mecho %BOOST_LIB%goto end:endpause 然后把文件保存为bat文件。
2、以管理员身份运行SetEnvironmentVariable.bat,如下图:
3、通过点击“我的电脑”,选择属性,找到并打开“高级系统配置”。在接下来的页面中点击“高级系统配置”,打开“系统属性”窗口,找到“环境变量”按钮并点击,可以看到环境变量已经设置上了,如下图: