kaixuan1115 / notes

笔记收录
6 stars 0 forks source link

批处理借助VBScript提升管理员权限 #9

Closed xiaokaixuan closed 5 years ago

xiaokaixuan commented 5 years ago
@echo off

:runas
openfiles 1>nul 2>&1 && goto :main
title 以管理员身份运行
mshta VBScript:Execute("CreateObject(""Shell.Application"").ShellExecute ""%~0"", Null, Null, ""runas"", 1: Close")
exit

:main
echo.
echo 当前正在以管理员身份运行...
echo.
pause
xiaokaixuan commented 3 years ago
@echo off

:runas
if not {%1}=={} goto :main
title 正在请求管理员权限...
mshta VBScript:Execute("CreateObject(""Shell.Application"").ShellExecute ""%~0"", ""::"", Null, ""runas"", 1: Close")
exit

:main
title 正在以管理员运行...
pause