echo -off

set Debug_Mode 0

if %1 == "" then
   goto Err_Print
endif

if not exist %1 then 
   goto No_File
endif

if exist fdtx64.efi then 
   del fdtx64.efi
endif

if exist fdt.smc then 
   mv fdt.smc fdtx64.efi
endif

if exist afuefi.smc then 
   mv afuefi.smc afuefix64.efi
endif

:Flash_BIOS
echo **************************************************************************
echo *
echo *  Please make sure system in manufacture mode now, switch JPME2 to Pin 
echo *  [2+3] to force system into manufacture mode.
echo *
echo *  Please refer to user manual page 2-30.
echo *
echo **************************************************************************

# Make sure system in manufacture mode
pause

# echo afuefix64.efi %1 /P /B /N /K /R /ME
afuefix64.efi %1 /P /B /N /K /R /ME /RLC:F
goto END

:No_File
echo **************************************************************************
echo *
echo *  %1 doesn't exist and please double check.
echo *
echo **************************************************************************
goto END1

:Err_Print
echo **************************************************************************
echo *
echo "*  Usage:"
echo "*         flash.nsh romfile"
echo *
echo **************************************************************************

:END
if exist fdtx64.efi then 
   copy fdtx64.efi fdt.smc
endif

if exist afuefix64.efi then 
   mv afuefix64.efi afuefi.smc
endif

echo **************************************************************************
echo *
echo *   System will reboot in 10 seconds....
echo *
echo *   If system under manufacture mode, please remember to set JPME2 
echo *   to PIN [1+2] to make system in Normal mode (Refer to user manual 
echo *   page 2-30).
echo *
echo **************************************************************************

echo 
Stall 10000000

fdtx64.efi -reset

:END1

