@echo off
@pushd %~dp0

Set MEName=ME_12_0_90_2072.bin

if [%1]==[] goto check
if %1==s goto update
:check
echo.
echo Updating Management Engine firmware will require a reboot in order for the update to be effective.  
echo.
set /P c=Do you want to update the Management Engine firmware now [Y/N]?
if /I "%c%" EQU "Y" goto update
if /I "%c%" EQU "N" goto exit

:update
set OS=64BIT
if %PROCESSOR_ARCHITECTURE% == x86 set OS=32BIT

if %OS%==32BIT goto update32
if %OS%==64BIT goto update64
goto exit

:update64
FWUpdLcl64 -fwver | find "FW Version" > FW.log
type fw.log | find "12."
if %ERRORLEVEL% NEQ 0 goto versionerr
FWUpdLcl64 -f %MEName%
if %ERRORLEVEL% NEQ 0 goto versionerr
echo Update complete. You must reboot your computer in order for the Management Engine firmware update to be effective. 
if [%1]==[] goto check1
if %1==s goto exit
:check1 
pause
goto exit

:update32
FWUpdLcl -fwver | find "FW Version" > FW.log
type fw.log | find "12."
if %ERRORLEVEL% NEQ 0 goto versionerr
FWUpdLcl -f %MEName%
if %ERRORLEVEL% NEQ 0 goto versionerr
echo Update complete. You must reboot your computer in order for the Management Engine firmware update to be effective.
if [%1]==[] goto check2
if %1==s goto exit
:check2
pause
goto exit
:versionerr
echo The ME update package not support current ME FW version.
echo Current ME FW version: 
type fw.log
if [%1]==[] goto check3
if %1==s goto exit
:check3
pause

:exit
