@echo off

Set PackageVersion=2.14

Set      Quanta_Uti_Name=HPBQ204.exe
Set     Wistron_Uti_Name=HPBW10D.exe
Set      Compal_Uti_Name=HPBC380.exe
Set    Inventec_Uti_Name=HPBI214.exe
Set Flextronics_Uti_Name=HPBFL237.exe
Set          bNB_Uti_Name=HpSet152.exe
Set     Foxconn_Uti_Name=HPBFO066.exe
Set    Pegatron_Uti_Name=HPBP121.exe
Set LockMpm=0
Set DesktopFlag=0
call setyear
echo Please correct the date
date

call iden
IF ERRORLEVEL 40 goto CHKVENDOR
IF ERRORLEVEL 37 goto DtUefiUpdateMe
IF ERRORLEVEL 36 goto DtUefiUpdateMe
IF ERRORLEVEL 35 goto DtUefiUpdateMe
IF ERRORLEVEL 34 goto DtUefiUpdateMe
IF ERRORLEVEL 33 goto bDT2013
IF ERRORLEVEL 32 goto bDT2012
IF ERRORLEVEL 31 goto bDT2011
IF ERRORLEVEL 30 goto bDT2010
IF ERRORLEVEL 27 goto ChkManu
IF ERRORLEVEL 26 goto ChkDmiEntry
IF ERRORLEVEL 25 goto CHKVENDOR
IF ERRORLEVEL 24 goto cNBC216I
IF ERRORLEVEL 23 goto cNBC216C
IF ERRORLEVEL 22 goto cNBC216W
IF ERRORLEVEL 21 goto cNBC216Q
IF ERRORLEVEL 20 goto cNBUEFI
IF ERRORLEVEL 19 goto cNBC316
IF ERRORLEVEL 18 goto CHKVENDOR
IF ERRORLEVEL 17 goto bNB201314
IF ERRORLEVEL 16 goto UefiUpdateMe
IF ERRORLEVEL 15 goto UefiUpdateMe
IF ERRORLEVEL 14 goto bNB2014
IF ERRORLEVEL 13 goto bNB2013
IF ERRORLEVEL 12 goto bNB2012
IF ERRORLEVEL 11 goto bNB2011
IF ERRORLEVEL 10 goto bNB2010
IF ERRORLEVEL 9 goto Pegatron
IF ERRORLEVEL 8 goto Foxconn
IF ERRORLEVEL 7 goto bNB
IF ERRORLEVEL 6 goto Flextronics
IF ERRORLEVEL 5 goto HP
IF ERRORLEVEL 4 goto IEC
IF ERRORLEVEL 3 goto Compal
IF ERRORLEVEL 2 goto Wistron
IF ERRORLEVEL 1 goto Quanta
IF ERRORLEVEL 0 goto CHKVENDOR
goto 10

:Quanta
call %Quanta_Uti_Name% /SetHPVer %PackageVersion%
goto lockMpm

:Wistron
call %Wistron_Uti_Name% /SetHPVer %PackageVersion%
goto lockMpm

:Compal
call %Compal_Uti_Name% /SetHPVer %PackageVersion%
goto lockMpm

:IEC
call %Inventec_Uti_Name% /SetHPVer %PackageVersion%

:lockMpm
If %LockMpm% == 0 goto exit
cls
echo *******************************************************
echo *********  You must boot to UEFI to lock MPM  *********
echo *******************************************************
goto exit

:HP
echo 5 HP
echo Manufacturer name programming error, current setting is: Hewlett-Packard in Type2/3
goto exit

:Flextronics
echo 6 Flextronics
call %Flextronics_Uti_Name% /SetHPVer %PackageVersion%
goto exit

:bNB
:echo 7 bNB
echo ************************************************************
echo *** You must program Serial number and other information ***
echo *** before running Branding tool to commit vPro/AMT      ***
echo ************************************************************

call %bNB_Uti_Name% 

if exist 08me.flg del 08me.flg
if exist 09me.flg del 09me.flg
if exist 11me.flg del 11me.flg
call amtsupp.exe
IF ERRORLEVEL 1 goto call_brand
goto exit

:call_brand
if exist 11me.flg goto 11me
call brand.bat
goto exit

:11me
echo **************************************************************
echo *** Boot to "External UEFI USB Drive" to commit AMT and AT ***
echo **************************************************************
pause
type Brand11.txt
goto exit

:Foxconn
echo 8 Foxconn
call %Foxconn_Uti_Name% /SetHPVer %PackageVersion%
goto exit

:Pegatron
echo 9 Pegatron
call %Pegatron_Uti_Name% /SetHPVer %PackageVersion%
goto exit

:bDT2013
Set MeUpdateFlag=33
Set DesktopFlag=1
goto UpdateMe

:bDT2012
Set MeUpdateFlag=32
Set DesktopFlag=1
goto UpdateMe

:bDT2011
Set MeUpdateFlag=31
Set DesktopFlag=1
goto UpdateMe

:bDT2010
Set MeUpdateFlag=30
Set DesktopFlag=1
goto UpdateMe

:bNB201314
Set MeUpdateFlag=17
goto UpdateMe

:bNB2014
Set MeUpdateFlag=14
goto UpdateMe

:bNB2013
Set MeUpdateFlag=13
goto UpdateMe

:bNB2012
Set MeUpdateFlag=12
goto UpdateMe

:bNB2011
Set MeUpdateFlag=11
goto UpdateMe

:bNB2010
Set MeUpdateFlag=10
goto UpdateMe

:UpdateMe
call updateme.bat

IF ERRORLEVEL 3 goto MeRet3
IF ERRORLEVEL 2 goto MeRet2
IF ERRORLEVEL 1 goto MeRet1
IF ERRORLEVEL 0 goto MeRet0
Echo Me Return unknown code

:MeRet3
goto DoneUpdateMe

:MeRet2
Echo Fail to get correct ME firmware version
goto DoneUpdateMe

:MeRet1
Echo Fail to update ME firmware
goto DoneUpdateMe

:MeRet0
Echo Update ME firmware successfully
goto DoneUpdateMe

:DtUefiUpdateMe
Set DesktopFlag=1

:UefiUpdateMe
echo **************************************************************
echo *** Boot to "External UEFI USB Drive" to update ME Firmware **

goto UEFIcommitvPro

:DoneUpdateMe
If %DesktopFlag% == 1 goto exit
If %MeUpdateFlag% == 11 goto bNB
If %MeUpdateFlag% == 10 goto bNB

:UEFIcommitvPro
echo **************************************************************
echo *** Boot to "External UEFI USB Drive" to commit AMT and AT ***
echo **************************************************************

:HP_bNB
If %DesktopFlag% == 1 goto exit
echo Please boot to windows and use wndmifit.exe to program DMI information
echo If the MPM mode is locked, escalate to 2LS to get SMC blob to unlock MPM
goto exit

:cNBUEFI
echo **************************************************************
echo ** Please boot to UEFI USB Drive to program DMI information **
echo **************************************************************
goto exit

:cNBC216I
Set CNBC216_ODM=4
goto cNBC216

:cNBC216C
Set CNBC216_ODM=3
goto cNBC216

:cNBC216W
Set CNBC216_ODM=2
goto cNBC216

:cNBC216Q
Set CNBC216_ODM=1
goto cNBC216

:cNBC216
echo *******  MPM must be unlocked on this platform before running DOS tool  *******
Choice Choose [y] to reboot to UEFI to unlock MPM, or [n] to run the DOS tool
If ERRORLEVEL 2 goto checkCnbC216Vendor
If ERRORLEVEL 1 goto exit

:checkCnbC216Vendor
Set LockMpm=1
If %CNBC216_ODM% == 4 goto IEC
If %CNBC216_ODM% == 3 goto Compal
If %CNBC216_ODM% == 2 goto Wistron
If %CNBC216_ODM% == 1 goto Quanta
goto exit

:cNBC316
echo.
echo ***  MPM must be unlocked on this platform before running Windows tool  ***
echo Please boot to Windows/WinPE and use wndmifit.exe to program DMI information
goto exit

:ChkManu
echo Error --> Can't find the valuable Manufacturer information
goto exit

:CHKVENDOR
echo Vendor code not support in this package
goto exit

:ChkDmiEntry
echo unexpect error
goto exit


:exit
