bat文件设置环境变量脚本
:: 获取管理员权限 @echo off %1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit cd /d "%~dp0" @echo off wmic ENVIRONMENT where name="OSG_FILE_PATH2" delete wmic ENVIRONMENT create name="OSG_FILE_PATH2",username="<system>",VariableValue="%~dp0" taskkill /f /im explorer.exe start explorer.exe pause
脚本如上所示,
1.首先获得管理员权限;
2.删除环境变量,保证创建环境变量成功
3.创建环境变量
4.重启explorer.exe资源浏览器