:: 获取管理员权限
@echo off
% mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",)(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资源浏览器

05-17 02:04