@echo off
REM #     cfgbios.cmd  - script to configure BIOS
REM #
REM set syscfgd=%DeployPath%\win32\syscfg
REM set cfgfile=%DeploymentStore%\cfgbios.scf
REM set logfile=%DeploymentStore%\cfgbios.log
set syscfgd=x:\deploy\win32\syscfg
set cfgfile=cfgbios.scf
set logfile=\cfgbios.log
set ADDLOG=call addLogRecord
REM set ADDLOG=echo
set RET=0

pushd %syscfgd%
syscfg /d BIOS >%logfile% 2>&1
if errorlevel 1 goto cfgserror

REM # save the BIOS configuration
del %cfgfile% 2>>%logfile%
echo syscfg /s %cfgfile% /b >>%logfile% 
syscfg /s %cfgfile% /b >>%logfile% 2>&1
if errorlevel 1 goto cfgserror
 %ADDLOG% CFGBIOS INFO "Success: BIOS config %cfgfile% saved"
 goto cfgsdone
:cfgserror
 set RET=%ERRORLEVEL%
 %ADDLOG% CFGBIOS ERROR "Error %ERRORLEVEL%: BIOS config save"
:cfgsdone

REM # restore the BIOS configuration
echo syscfg /r %cfgfile% /b >>%logfile% 
syscfg /r %cfgfile% /b >>%logfile% 2>&1
if errorlevel 1 goto cfgrerror
 %ADDLOG% CFGBIOS INFO "Success: BIOS config %cfgfile% restored"
 goto cfgrdone
:cfgrerror
 set RET=%ERRORLEVEL%
 %ADDLOG% CFGBIOS ERROR "Error %ERRORLEVEL%: BIOS config restore"
:cfgrdone
popd
echo cfgbios with %cfgfile% done, ret=%RET%
exit /B %RET%
