@echo off
setlocal enabledelayedexpansion
net session >nul 2>&1
if %errorlevel% equ 0 (
    goto :gotAdmin
)

echo Set UAC = CreateObject("Shell.Application") > "%temp%\admin.vbs"
echo UAC.ShellExecute "cmd.exe", "/k cd /d ""%~dp0"" && ""%~f0""", "", "runas", 1 >> "%temp%\admin.vbs"
"%temp%\admin.vbs"
del "%temp%\admin.vbs" >nul 2>&1
exit /b

:gotAdmin
cd /d "%~dp0"


:: Set new PI version for compare such as Newversion=1.01
set Newversion=1.09
:: ============================

for /f "delims=" %%i in ('powershell -command "& { $v=(Get-CimInstance Win32_BIOS).SMBIOSBIOSVersion; $nums=[regex]::Matches($v,'\d+') | ForEach-Object { [int]$_.Value }; if ($nums.Count -ge 2) { $ver=[version]::new($nums[0],$nums[1]); if ($ver -lt [version]'%Newversion%') { 'OLD_VERSION' } else { 'NEW_VERSION' } } else { 'NEW_VERSION' } }"') do set "result=%%i"

if "%result%"=="OLD_VERSION" goto OLD
goto NEW

:OLD
:: need save OA3+DMI
cd backup_restore
call save.bat
cd ..
cls
echo.
echo  Please execute batch file  "Restore.bat"  to restore DMI and OA3 information after enter the OS !!!
echo  Please execute batch file  "Restore.bat"  to restore DMI and OA3 information after enter the OS !!!
echo  Please execute batch file  "Restore.bat"  to restore DMI and OA3 information after enter the OS !!!
:loop
SET /P ST=Please enter  "Y" to continue:
if /I "%ST%"=="y" goto NEW 
goto loop 
:NEW
@echo In silent refresh mode, the system will automatically shut down and enter BIOS setup for updates. Please wait...

AFUWINx64.EXE F8BAC.bin /p /b /n /k  /r /capsule /q
