@echo off
REM e:\Share\INVCOL_TEMP\libsmbios\smbiosinfo.exe -i | FIND "SystemID:"

PUSHD "%~dp0"

SET SMBIOSEXE=smbiosinfo.exe
REM SET SMBIOSEXE=%~dp0smbiosinfo.exe
ECHO %SMBIOSEXE%
SET INIFile="%~dp0SupportedSystems.ini"
REM ECHO "Look in File %INIFILE%"

SET KeyFound=0

FOR /F "tokens=2 delims= " %%i IN (' %SMBIOSEXE% -i ^| find "SystemID:"') DO SET systemID=%%i

REM ECHO Current SystemID=%systemID%

FOR /F "tokens=* delims=" %%i IN ('TYPE %INIFile%') DO CALL :ParseINI "%%i"
ECHO.

IF NOT %KeyFound%==1 (
	ECHO %systemID% is an UNSUPPORTED system
        POPD
	EXIT 100 )
IF %KeyFound%==1         ( 
	ECHO %systemID% is a SUPPORTED system
        POPD
	EXIT 200 )



:ParseINI

IF %KeyFound%==1 GOTO :EOF
REM echo %KeyFound%

::Store line in a variable
SET Line="%~1"
REM echo Line = %Line%


:: Parse any "key=value" line
FOR /F "tokens=1* delims==" %%a IN ('ECHO.%Line%') DO (
    SET Key=%%a^"
    SET Value=^"%%b
)

:: Strip quotes, tabs, and surrounding spaces from key and value
:: Modifications added by Van Woods,
:: US Army Corps of Engineers, Seattle District
SET Value=%Value:"=%
:: Remove quotes
SET Key=%Key:"=%
:: Remove tabs
SET Value=%Value:	=%
SET Key=%Key:	=%
:: Remove leading spaces
FOR /F "tokens=* delims= " %%A IN ("%Key%")   DO SET Key=%%A
FOR /F "tokens=* delims= " %%A IN ("%Value%") DO SET Value=%%A
:: Remove trailing spaces
FOR /L %%A in (1,1,32) do if "!Key:~-1!"==" " set Key=!Key:~0,-1!
FOR /L %%A in (1,1,32) do if "!Value:~-1!"==" " set Value=!Value:~0,-1!

:: Now check if the key matches the required key
IF /I "%Value%"=="%SystemID%" (
    SET INIValue=%Key%
    SET KeyFound=1
)

:: End of ParseINI subroutine
GOTO:EOF


