@ECHO OFF

SET ReturnCode=0

CLS

echo WARNING: Please make sure system is plugged in for ME Firmaware update (AC Mode is Recommended) !
echo............................
echo Updating the ME Firmware...
echo............................

rem =============================Check for vPro=============================
"%~dp0TpDevPE.exe" /CM "PCI\VEN_8086&DEV_9DE3"
if errorlevel 1 GOTO NonvPro_Install
rem =============================Check for vPro=============================

:Corporate

echo Corporate System detected.
:: "%~dp0FwDetect.exe" /fw 15.0.30.1776 %~dp0NUL
IF errorlevel 0 (
pnputil /add-driver "%~dp0Capsule\Corporate\TglMe_15_0_30_1776_H_Corp.inf" /install
SET ReturnCode=%errorlevel%
GOTO RESTART 
) ELSE (
echo System already have latest MEFW version
)
GOTO END

:Consumer

echo Consumer system detected.
:: "%~dp0FwDetect.exe" /fw 15.0.30.1776  %~dp0NUL
IF errorlevel 0 (
pnputil /add-driver "%~dp0Capsule\Consumer\TglMe_15_0_30_1776_H_Cons.inf" /install
SET ReturnCode=%errorlevel%
GOTO RESTART ) ELSE (
echo System already have latest MEFW version
)
GOTO END


:RESTART
echo System will now Restart for Capsule update in 5 seconds
TIMEOUT 6
echo ......
IF [%1]==[] Shutdown.exe -r -t 10 && exit /b %ReturnCode%

exit /b %ReturnCode%

:END
