Created
February 10, 2018 03:29
-
-
Save miyouzi/a0fce09a05f231928b4b48354799002d to your computer and use it in GitHub Desktop.
批处理自动尝试提权
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REM =============================检查并尝试获取管理员权限============================== | |
REM 借鉴 https://sites.google.com/site/eneerge/home/BatchGotAdmin | |
:getadmin | |
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" | |
if '%errorlevel%' NEQ '0' ( | |
echo 【正在尝试获取管理员权限】 | |
mshta vbscript:"<html style=background:buttonface><title>BatchGetAdmin</title><body><script language=vbscript>Set UAC = CreateObject(""Shell.Application""):UAC.ShellExecute ""%~s0"", """", """", ""runas"", 1:self.close</script></body></html>" | |
exit | |
) | |
goto :eof | |
REM ================================================================================== |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment