echo -off

if exist SUM.smc then
   mv SUM.smc SUM.efi
endif

if not %1 == "" then
   if not %2 == "" then
      if not %3 == "" then
        goto Check_BIOS
      endif
   endif
endif

echo *******************************************************************************
echo *
echo *  Usage: flash.nsh <BMC Username> <BMC Password> <BIOS Filename>
echo *  
echo *  Please use the BMC account with the administrator privilege!
echo *
echo *******************************************************************************
goto END

:Check_BIOS

if not exist %3 then
   goto No_File
endif

:Flash_BIOS
echo *******************************************************************************
echo *
echo *  Program BIOS and ME regions...
echo *
echo *  The system will REBOOT automatically to complete the BIOS update, after
echo *  uploading the BIOS image to BMC.
echo *
echo *  Press any key to continue, or q or Q to abort.
echo *
echo *******************************************************************************
pause -q

echo *******************************************************************************
echo *
echo *  Start flashing BIOS with BIOS: %3!
echo *  Please do not reboot the system.  Entering SUM...
echo *
echo *******************************************************************************
echo "SUM.efi -I Redfish_HI -u %1 -p %2 -c UpdateBIOS --file %3 --reboot"
SUM.efi -I Redfish_HI -u %1 -p %2 -c UpdateBIOS --file %3 --reboot

goto END

:No_File
echo *******************************************************************************
echo *
echo *  %3 does not exist!  Please verify the filename & try again.
echo *
echo *  Usage: flash.nsh <BMC Username> <BMC Password> <BIOS Filename>
echo *
echo *  Please use BMC account with administrator privilege!
echo *
echo *******************************************************************************

:END
if exist SUM.efi then
   mv SUM.efi SUM.smc
endif
