:For auto backup UUID before flash BIOS and auto recover UUID from backup UUID file after falsh BIOS.

@echo off

if exist recover.txt goto recover
if exist finish.txt goto finish

::backup
echo Check the previous Mothor Board's UUID backup file...
if exist UUID.txt del UUID.txt

echo Start to backup Mothor Board's UUID...

XDDMI.exe /RF /SU UUID.txt
if errorlevel 1 goto backupeeror
if errorlevel 0 echo Backup UUID successful...

::Flash BIOS
echo Start to flash BIOS...
cd BIOS
if exist AFUDOS.exe echo System BIOS should to be flashed ... > sys.txt
if exist fpt.exe echo ME should to be flashed ... > me.txt

if exist sys.txt call dosflash.bat
if errorlevel 1 goto flasherror
if exist sys.txt del sys.txt

if exist me.txt call flash.bat
if errorlevel 1 goto flasherror
if exist me.txt del me.txt

echo Flash BIOS finished...
cd ..
echo recover > recover.txt
goto restar

:recover
XDDMI.exe /WF /SU 16 UUID.txt
if errorlevel 1 goto recerror
if exist recover.txt del recover.txt
echo Recover UUID successful!
echo  
echo finish > finish.txt
goto restar

:finish
if exist finish.txt del finish.txt
echo Process complete!
goto end

:restar
fbshut /2

:backupeeror
echo Backup UUID error...
goto end

:recerror
echo Recover UUID error...
goto end

:flasherror
echo  Flash BIOS error...
goto end

:end


