@echo off
set BIOS_NAME=ARWSA.bin
%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit
cd /d "%~dp0"
FPTW64.exe -f  %BIOS_NAME% -y
where wmic >nul 2>&1
if %errorlevel% equ  0 (
for /f "skip=1 tokens=2 delims==" %%a in ('wmic baseboard get serialnumber /value') do set "BSN=%%a"
for /f "skip=1 tokens=2 delims==" %%a in ('wmic bios get serialnumber /value') do set "SSN=%%a"
for /f "skip=1 tokens=2 delims==" %%a in ('wmic csproduct get uuid /value') do set "uuid=%%a"
set "uuid=%uuid:-=%"
set Data1_0=%uuid:~6,2%
set Data1_1=%uuid:~4,2%
set Data1_2=%uuid:~2,2%
set Data1_3=%uuid:~0,2%
set Data2_0=%uuid:~10,2%
set Data2_1=%uuid:~8,2%
set Data3_0=%uuid:~14,2%
set Data3_1=%uuid:~12,2%
set Data4=%uuid:~16,16%
set uuid=%Data1_0%%Data1_1%%Data1_2%%Data1_3%%Data2_0%%Data2_1%%Data3_0%%Data3_1%%Data4%
REM TIMEOUT /T 5 /NOBREAK
AMIDEWINx64.EXE /SS "%SSN%" /SU "%uuid%" /BS "%BSN%"
if %errorlevel% neq 0 (
del SMBIOS.bat
echo For special reasons, the machine must be restarted, and then manually run SMBIOS.bat under the current path to maintain DMI.
echo @echo off >> SMBIOS.bat
echo %%1 mshta vbscript:CreateObject^(^"Shell.Application^"^).ShellExecute^(^"cmd.exe^",^"/c %%~s0 ::^",^"^",^"runas^",1^)^(window.close^)^&^&exit >> SMBIOS.bat
echo cd /d ^"%%^~dp0^" >> SMBIOS.bat
echo AMIDEWINx64.EXE /SS ^"%SSN%^" /SU ^"%uuid%^" /BS ^"%BSN%^" >> SMBIOS.bat
PAUSE
)
)
AFUWINx64.exe %BIOS_NAME% /n /x /cmd:{EC} /shutdown
:END