@echo off
rem MODE con: COLS=100 LINES=30>nul
ver | find " 5." > NUL &&goto :cmdbegin
for /f "tokens=3,*" %%I in ('reg query "HKLM\SYSTEM\CurrentControlSet\Control" /v SystemStartOptions') do set "MININT=%%I"
echo %MININT%|find /i "MININT" 1>nul 2>nul&&goto :cmdbegin
rem EnableLUA不能设置为0,否则标准用户无法弹出管理员账号密码,就无法用管理员身份运行程序。
rem reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System" /f /v EnableLUA /t REG_DWORD /d 1
if not defined username set "username=system"
net localgroup "users"|find /i "%username%" 1>nul 2>nul&&set "user=standard"
net localgroup "administrators"|find /i "%username%" 1>nul 2>nul&&set "user=administrator"
for /f "tokens=3,*" %%I in ('reg query "HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System" /v EnableLUA') do set "EnableLUA=%%I"
if "%user%"=="standard" if "%EnableLUA%"=="0x0" goto :cmdbegin
md "%SystemRoot%\system32\tempXXX" 2>nul
if exist "%SystemRoot%\system32\tempXXX" (rd /s /q "%SystemRoot%\system32\tempXXX") else (
if exist "%temp%\getadmin.vbs" del /f /q "%temp%\getadmin.vbs"
echo set uac = CreateObject^("Shell.Application"^)>"%temp%\getadmin.vbs"
echo uac.ShellExecute "%~s0","","","runas",1 >>"%temp%\getadmin.vbs"
echo WScript.Quit >>"%temp%\getadmin.vbs"
rem ping 127.0.0.1 -n 5 >nul
"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs" 1>nul 2>nul
exit /b)
:cmdbegin
rem ===================以上代码可让该批处理自动以管理员身份运行===========================
rem pause
@echo off
rem 判断64位系统和32位系统
for /f "tokens=3,*" %%I in ('reg query "HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0" /v Identifier^|find /i "Identifier"') do if not defined PROCESSOR_IDENTIFIER set "PROCESSOR_IDENTIFIER=%%I"
echo %PROCESSOR_IDENTIFIER%
if /i %PROCESSOR_IDENTIFIER:~0,3%==x86 (
echo 32位操作系统
) else (
echo 64位操作系统
)
pause