bat脚本中以管理员权限执行命令

%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit

 

 

 

2021年1月9日补充

如果遇到有文件夹名称有空格的情况下,可以将 %~s0 改为 ""%~s0"" 以支持路径中有空格后无法正确执行的问题。

 

也就是     %1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c ""%~s0"" ::","","runas",1)(window.close)&&exit

posted @ 2020-09-18 12:54  黑羽青衣  阅读(3414)  评论(1编辑  收藏  举报