@Echo off
REM BRAND.BAT - Commit a system as AMT-enabled or AMT-disabled

ready2br.exe
if errorlevel 1 goto donechk

:dont_run
if exist brand.flg del brand.flg
goto done
 
:donechk
if exist c:\MEINFO.TXT del c:\MEINFO.TXT
CLS
set pause=1

:chk_cfg
cls
REM -- This call sets %locked% variable ----
call rlk.bat
echo .
if %EL% == 1 goto end_err

REM -- This call sets %cpro_state% variable ----
call rcfg.bat
if %EL% == 1 goto exit_err 

REM -- This call sets %me_state% variable ---
call rme.bat
if %EL% == 1 goto exit_err 

If %locked% == 1 goto cfg_locked 
If %cpro_state% == Uncommited goto uncommitted
If %cpro_state% == Centrino_Pro goto lock_down
If %cpro_state% == NOT_Centrino_Pro goto lock_down
goto end_err

:uncommitted
cls
cpqamt read  
Echo ********************************************
@Echo .
Choice Do you want to enable or disable *vPro_AMT* now 
Echo .
If errorlevel 2 goto end
If errorlevel 1 goto choose
goto end

:choose
cls
@Echo .
Choice Choose [Y] to Enable vPro_AMT, or [N] to Disable vPro_AMT 
If errorlevel 2 goto non_cpro
If errorlevel 1 goto cpro

:non_cpro
cls
@Echo .
Choice Are you sure to *Disable* vPro_AMT 
If errorlevel 2 goto uncommitted
call nvp.bat
if %EL% == 1 goto end_err
goto global_reset

:cpro
cls
@Echo .
Choice Are you sure to *Enable* vPro_AMT 
If errorlevel 2 goto uncommitted
call vp.bat
if %EL% == 1 goto end_err
goto global_reset

:global_reset
echo reset the system>brand.flg
cpqamt reboot                  
pause

:lock_down
cls 
call lk.bat
if %EL% == 1 goto end_err
goto global_reset

:end_err
Echo ********************************* 
Echo *      Exit with errors!     *
Echo ********************************* 
goto end

:cfg_locked
REM check the platforms via MEINFO
meinfo.exe > C:\MEINFO.TXT

REM ME remains enabled for 2009 and later Platforms
find /c /i "FW Version:                             6." C:\MEINFO.TXT
  if not errorlevel=1 goto end

REM ME is decided by the vPro/AMT state for 2007 and 2008 platforms
If %cpro_state% == Centrino_Pro goto chkme_enable
If %cpro_state% == NOT_Centrino_Pro goto chkme_disable 
goto end_err

:chkme_enable
If %me_state% == Enabled goto end
goto end_err

:chkme_disable
If %me_state% == Disabled goto end
goto end_err

:end
@Echo off
if exist brand.flg del brand.flg
del c:\MEINFO.TXT
cls
REM -- print state to screen --
cpqamt read
Echo.
@Echo ******************
@Echo  End of execution                     
@Echo ******************
:done