@echo off
SETLOCAL ENABLEDELAYEDEXPANSION

REM + ============================================================== +
REM  Copyright (c) 2025, Intel Corporation.

REM  This source code and any documentation accompanying it ("Material") is furnished
REM  under license and may only be used or copied in accordance with the terms of that
REM  license.  No license, express or implied, by estoppel or otherwise, to any
REM  intellectual property rights is granted to you by disclosure or delivery of these
REM  Materials.  The Materials are subject to change without notice and should not be
REM  construed as a commitment by Intel Corporation to market, license, sell or support
REM  any product or technology.  Unless otherwise provided for in the license under which
REM  this Material is provided, the Material is provided AS IS, with no warranties of
REM  any kind, express or implied, including without limitation the implied warranties
REM  of fitness, merchantability, or non-infringement.  Except as expressly permitted by
REM  the license for the Material, neither Intel Corporation nor its suppliers assumes
REM  any responsibility for any errors or inaccuracies that may appear herein.  Except
REM  as expressly permitted by the license for the Material, no part of the Material
REM  may be reproduced, stored in a retrieval system, transmitted in any form, or
REM  distributed by any means without the express written consent of Intel Corporation.

REM  Module Name:  bios_cap_update.bat

REM  Abstract:  Batch Script file for invoking system software updates for
REM  Intel(R) Server Board D50DNP Family.


set CWD=%cd%
set BASE_PATH=%CWD%\sysfwupdt\Win_x64
set ITK_CAP=R01.02.0006_CAPSULE_Customized_signed.cap
set ARG=%1


CALL :start
EXIT /B %ERRORLEVEL% 

:start
	if "%ARG%"=="" (
		CALL driver_install.bat no_restart
	)
	cd %BASE_PATH%
	CALL :biosupdate
	CALL :restart
	EXIT /B 0
echo.
		
:biosupdate
	echo.
	echo.
	echo "===================================================== BIOS ITK UPDATE ====================================================="
	echo.
	echo "Updating BIOS ITK ..."
	echo "sysfwupdt.exe -u ..\..\%ITK_CAP% UpdateNvram+ImmReset"
	sysfwupdt.exe -u ..\..\%ITK_CAP% UpdateNvram+ImmReset
	EXIT /B 0
	
:restart
	echo.
	echo.
	if "%ARG%"=="" (
		echo "Restarting system in 1 minute, System will take approximately 10 minutes to boot back"
		c:\windows\system32\shutdown.exe -r -t 60
		echo.
		echo "**************************************************************"
		echo "To abort the scheduled restart, use 'shutdown -a' command."
		echo "**************************************************************"
	)
	EXIT /B 0
