|
本帖最后由 comzhongwy 于 2017-12-28 11:25 编辑
你觉得哪种写法更好?
- @ECHO OFF
- setlocal ENABLEDELAYEDEXPANSION
- mode con: cols=65 lines=25
- color 0a
- :-------------------------------------
- echo 检查管理员权限
- >NUL 2>&1 REG.exe query "HKU\S-1-5-19" || (
- ECHO SET UAC = CreateObject^("Shell.Application"^) > "%TEMP%\Getadmin.vbs"
- ECHO UAC.ShellExecute "%~f0", "%1", "", "runas", 1 >> "%TEMP%\Getadmin.vbs"
- CSCRIPT //Nologo "%TEMP%\Getadmin.vbs"& DEL /f /q "%TEMP%\Getadmin.vbs" 2>NUL& Exit)
- pushd "%CD%"&& CD /D "%~dp0"
- :-------------------------------------
- echo 检查 管理员权限...
- >NUL 2>&1 REG.exe query "HKU\S-1-5-19" || (
- echo CreateObject^("Shell.Application"^).ShellExecute "%~f0", "%1", "", "runas", 1 > "%TEMP%\AdminRun.vbs"
- echo CreateObject^("Scripting.filesystemobject"^).DeleteFile ^(WScript.ScriptFullName^) >> "%TEMP%\AdminRun.vbs"
- CSCRIPT //Nologo "%TEMP%\Getadmin.vbs"& DEL /f /q "%TEMP%\Getadmin.vbs" 2>NUL& Exit)
- pushd "%CD%"&& CD /D "%~dp0"
- :--------------------------------------
- echo 检查管理员权限
- >nul 2>&1 %Windir%\System32\FLTMC.exe || (
- ECHO SET UAC = CreateObject^("Shell.Application"^) > "%TEMP%\Getadmin.vbs"
- ECHO UAC.ShellExecute "%~f0", "%1", "", "runas", 1 >> "%TEMP%\Getadmin.vbs"
- CSCRIPT //Nologo "%TEMP%\Getadmin.vbs"& DEL /f /q "%TEMP%\Getadmin.vbs" 2>NUL& Exit)
- pushd "%CD%"&& CD /D "%~dp0"
- :-------------------------------------
- echo 检查 管理员权限...
- >nul 2>&1 dir "%WinDir%\system32\config" || (
- set vbs=Set UAC ^= CreateObject(""Shell.Application""):^
- UAC.ShellExecute ""%~0"", """", """", ""runas"", 1:window.close
- mshta VBScript:Execute("%vbs%")&& exit)
- pushd "%CD%"&& CD /D "%~dp0"
- :-------------------------------------
- echo 检查 管理员权限...
- >nul 2>&1 dir "%WinDir%\system32\config" || (
- mshta VBScript:CreateObject("Shell.Application").ShellExecute("%~s0","goto :gotAdmin","","runas",1)(window.close)&& exit)
- pushd "%CD%"&& CD /D "%~dp0"
- :-------------------------------------
- echo 检查 管理员权限...
- %1 mshta vbscript:createobject("shell.application").shellexecute("""%~0""","::",,"runas",1)(window.close)&& exit
- pushd "%CD%"&& CD /D "%~dp0"
- :-------------------------------------
- echo 检查 管理员权限...
- %1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&& exit
- pushd "%CD%"&& CD /D "%~dp0"
- :-------------------------------------
- ::以下为你的批处理内容
- pause
复制代码
|
|