@echo off
set DOS4G=quiet
set FTEXT=NULL.txt
set FBAT=fh.bat
set KDMI=0
IF [%2] == [k] set KDMI=k
IF [%1] == [1] goto :FlashS
IF [%1] == [2] goto :FlashS
IF [%1] == [3] goto :FlashS
IF [%1] == [4] goto :FlashS
IF [%1] == [5] goto :FlashS
IF [%1] == [51] goto :Delfile
IF [%1] == [52] goto :Ctefile
goto :Help

:FlashS
cls
echo !!!!!!!!!!!!!!!!!!!!!     Notice     !!!!!!!!!!!!!!!!!!!!!
echo !!   If your BIOS is formal version (F/R/P)             !!
echo !!   This Tool will auto update your DMI data.          !!
echo !!   Whole BIOS flash sequence include DMI restore.     !!
echo !!                                                      !! 
echo !!   If your system default first boot device is not    !!
echo !!   this USB device(now used), plese select this USB   !!
echo !!   device to boot for DMI restore and plese watting   !!
echo !!   for DMI resotre complete.                          !!
echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!  
pause
cls
echo ====================GigaByte Flash BIOS Utility v1.0====================
echo waitting for create necessary flash file.
IF EXIST bv.txt del bv.txt
IF EXIST BVF.txt del BVF.txt
IF %KDMI% == 0 FLA.EXE 5
IF EXIST %FBAT% del %FBAT%

FLA.EXE 11 %FTEXT% %FBAT%
IF %1 == 1 goto :One
IF %1 == 2 goto :Two
IF %1 == 3 goto :Thr
IF %1 == 4 goto :Fur
IF %1 == 5 goto :Two2
goto :Done

:One
echo execute 1 sequence, use FPT flash BIOS and Afudos flash ME.
%FBAT% 1 %KDMI%
goto :Done

:Two2
echo Set ME jumpter to recovery mode, use FPT to flash whole BIOS and ME.
%FBAT% 7 %KDMI%
goto :Done

:Two
echo execute 2 sequence, use FPT to flash whole BIOS and ME.
%FBAT% 4 %KDMI%
goto :Done

:Thr
echo execute 3 sequence, use AfuDos to flash BIOS region.
%FBAT% 5 %KDMI%
goto :Done

:Fur
echo execute 4 sequence, use AfuDos to flash BIOS and ME region.
%FBAT% 6 %KDMI%
goto :Done

:Delfile
IF EXIST %2 del %2
goto :Done

:Ctefile
IF EXIST %2 del %2
type NUL > %2
goto :Done

:Help
echo please use fb.bat [1/2/3/4] [k]
echo !! Notice, if your BIOS is formal version (F/R/P).
echo !! System will auto restore DMI data.
echo [1] = use FPT flash BIOS, Afudos flash ME. Please don't set ME Flash jumper.
echo [2] = use FPT flash BIOS and ME. Must set ME Flash jumper.
echo [3] = use AfuDos flash BIOS.
echo [4] = use AfuDos flash BIOS + ME region.
echo [k] = force to Keep previous DMI data.
goto :Done

:Done