A.bat- @echo off
- @REM 获取管理员权限.
- >nul fltmc.exe||mshta vbscript:CreateObject("Shell.Application").ShellExecute("%~s0",,,"runas",1)(window.close)&&exit
- cd /d "%~dp0"
-
- echo do admin works
-
- @REM 非管理员运行的B.bat
- set "batb=%cd%\B.bat"
- >nul schtasks.exe /Create /TN "\Windows\Unelevate" /TR "%comspec% /c \"\"%batb%\"\"" /SC ONCE /ST 00:00 /F
- >nul schtasks.exe /Run /TN "\Windows\Unelevate"
-
- @REM 没必要删除计划任务
- @REM >nul schtasks.exe /Delete /TN "\Windows\Unelevate" /F
复制代码
|