@echo off
rem *** Author: T. Wittrock, RZ Uni Kiel ***

if "%OS_VERSION_MAJOR%"=="" goto NoOSVersion

set WUA_VERSION_TARGET_MAJOR=5
set WUA_VERSION_TARGET_MINOR=8
set WUA_VERSION_TARGET_BUILD=0
set WUA_VERSION_TARGET_REVISION=2694

set MSI_VERSION_TARGET_BUILD=0
set MSI_VERSION_TARGET_REVISION=0

set WSH_VERSION_TARGET_MAJOR=5
set WSH_VERSION_TARGET_MINOR=6
set WSH_VERSION_TARGET_BUILD=0
set WSH_VERSION_TARGET_REVISION=0

set IE_VERSION_TARGET_MINOR=0
set IE_VERSION_TARGET_BUILD=0
set IE_VERSION_TARGET_REVISION=0

set DIRECTX_VERSION_TARGET_MAJOR=4
set DIRECTX_VERSION_TARGET_MINOR=09
set DIRECTX_VERSION_TARGET_BUILD=00
set DIRECTX_VERSION_TARGET_REVISION=0904

set DOTNET_VERSION_TARGET_MAJOR=3
set DOTNET_VERSION_TARGET_MINOR=5
set DOTNET_VERSION_TARGET_BUILD=30729
set DOTNET_VERSION_TARGET_REVISION=1

if %OS_VERSION_MAJOR% LSS 5 goto SetOfficeName
if %OS_VERSION_MAJOR% GTR 6 goto SetOfficeName
if %OS_VERSION_MAJOR% EQU 5 (
  if %OS_VERSION_MINOR% GTR 2 goto SetOfficeName
)
if %OS_VERSION_MAJOR% EQU 6 (
  if %OS_VERSION_MINOR% GTR 0 goto SetOfficeName
)
goto Windows%OS_VERSION_MAJOR%.%OS_VERSION_MINOR%

:Windows5.0
rem *** Windows 2000 ***
set OS_NAME=w2k
set OS_SP_VERSION_TARGET_MAJOR=4
set OS_SP_TARGET_ID=W2KSP4
set MSI_VERSION_TARGET_MAJOR=3
set MSI_VERSION_TARGET_MINOR=1
set MSI_TARGET_ID=KB893803
set IE_VERSION_TARGET_MAJOR=6
goto SetOfficeName

:Windows5.1
rem *** Windows XP ***
set OS_NAME=wxp
set OS_SP_VERSION_TARGET_MAJOR=3
set OS_SP_TARGET_ID=KB936929
set MSI_VERSION_TARGET_MAJOR=4
set MSI_VERSION_TARGET_MINOR=5
set MSI_TARGET_ID=KB942288
if /i "%1"=="/instie7" (set IE_VERSION_TARGET_MAJOR=7) else (set IE_VERSION_TARGET_MAJOR=6)
goto SetOfficeName

:Windows5.2
rem *** Windows Server 2003 ***
set OS_NAME=w2k3
set OS_SP_VERSION_TARGET_MAJOR=2
set OS_SP_TARGET_ID=KB914961
set MSI_VERSION_TARGET_MAJOR=4
set MSI_VERSION_TARGET_MINOR=5
set MSI_TARGET_ID=KB942288
if /i "%1"=="/instie7" (set IE_VERSION_TARGET_MAJOR=7) else (set IE_VERSION_TARGET_MAJOR=6)
goto SetOfficeName

:Windows6.0
rem *** Windows Vista / Server 2008 ***
set OS_NAME=w60
set OS_SP_VERSION_TARGET_MAJOR=1
set OS_SP_TARGET_ID=KB936330
set MSI_VERSION_TARGET_MAJOR=4
set MSI_VERSION_TARGET_MINOR=0
set MSI_TARGET_ID=KB942288
set IE_VERSION_TARGET_MAJOR=7
goto SetOfficeName

:SetOfficeName
if "%OFFICE_VERSION_MAJOR%"=="" goto EoF
if %OFFICE_VERSION_MAJOR% LSS 9 goto EoF
if %OFFICE_VERSION_MAJOR% GTR 12 goto EoF
goto Office%OFFICE_VERSION_MAJOR%

:Office9
rem *** Office 2000 ***
set OFFICE_NAME=o2k
set OFFICE_SP_VERSION_TARGET=3
set OFFICE_SP_TARGET_ID=O2kSp3
if %OFFICE_SP_VERSION% EQU 0 set O2K_PREC_SP_TARGET_ID=o2ksr1adl
goto EoF

:Office10
rem *** Office XP ***
set OFFICE_NAME=oxp
set OFFICE_SP_VERSION_TARGET=3
set OFFICE_SP_TARGET_ID=KB832671
goto EoF

:Office11
rem *** Office 2003 ***
set OFFICE_NAME=o2k3
set OFFICE_SP_VERSION_TARGET=3
set OFFICE_SP_TARGET_ID=KB923618
goto EoF

:Office12
rem *** Office 2007 ***
set OFFICE_NAME=o2k7
set OFFICE_SP_VERSION_TARGET=1
set OFFICE_SP_TARGET_ID=KB936982
goto EoF

:NoOSVersion
echo.
echo ERROR: Environment variable OS_VERSION_MAJOR not set.
echo.
exit /b 1

:EoF
