echo off
echo Build inf2cat OsVersion string
rem set default OS to windows 10 x86 edition, windows 10 x64 edition
rem windows 8 s86 edition, windows 8 x64 edition,
set OS=10_X64,10_X86
if exist inf.txt del inf.txt
if exist fout.txt del fout.txt
inf2cat.exe > inf.txt

echo Look for Windows Server RS5 x64 Edition (ServerR5_X64) build 1809 10.0.17763.XXX in output 
find /c "ServerRS5_X64" inf.txt > fout.txt
if NOT %ERRORLEVEL% == 0 goto LookR4
set OS=%OS%,ServerRS5_X64
goto FindServ10

:LookR4
echo Looking for Windows Server RS4 x64 Edition (ServerR4_X64) build 1803 10.0.17134.XXX 
find /c "ServerRS4_X64" inf.txt > fout.txt
if NOT %ERRORLEVEL% == 0 goto FindServ10
set OS=%OS%,ServerRS4_X64

:FindServ10
echo Looking for Windows Server 2016 (Server10_X64) in output
find /c "Server10_X64" inf.txt > fout.txt
if NOT %ERRORLEVEL% == 0 goto Find2016
set OS=%OS%,Server10_X64

:Find2016
echo Look for Windows Server 2016 (Server2016_X64) in output
find /c "Server2016_X64" inf.txt > fout.txt
if NOT %ERRORLEVEL% == 0 goto Find2012R2
set OS=%OS%,Server2016_X64

:Find2012R2
echo Looking for Windows server 2012 R2 (Server6_3_X64) OS Build 6.3.9600
find /c "Server6_3_X64" inf.txt > fout.txt
if NOT %ERRORLEVEL% == 0 goto Find2012
set OS=%OS%,Server6_3_X64

goto end

:Find2012
echo Looking for Windows server 2012 (Server8_X64) OS Build 6.3.9200
find /c "Server6_3_X64" inf.txt > fout.txt
if NOT %ERRORLEVEL% == 0 goto Find8_1_64
set OS=%OS%,Server8_X64

:Find8_1_64
echo Looking for X64 windows 8.1 (6_3_X64) OS build 6.3.9600
find /c "6_3_X64" inf.txt > fout.txt
if NOT %ERRORLEVEL% == 0 goto Find8_1_86
set OS=%OS%,6_3_X64

:Find8_1_86
echo Looking for X86 windows 8.1 (6_3_X86) OS build 6.3.9600
find /c "6_3_X86" inf.txt > fout.txt
if NOT %ERRORLEVEL% == 0 goto Find8_64
set OS=%OS%,6_3_X86

:Find8_64
echo Looking for X64 windows 8 (8_X64) OS build 6.3.9200
find /c "6_3_X64" inf.txt > fout.txt
if NOT %ERRORLEVEL% == 0 goto Find8_86
set OS=%OS%,8_X64

:Find8_86
echo Looking for X86 windows 8 (8_X86) OS build 6.3.9200
find /c "6_3_X86" inf.txt > fout.txt
if NOT %ERRORLEVEL% == 0 goto Next
set OS=%OS%,8_X86

:Next



:end
echo OS=%OS%
if exist fout.txt del fout.txt
if exist inf.txt del inf.txt
