@title Build configuration for unattended installation

@set ARCHCHOICES=Select architecture (
@if exist "CFG\x86"\ @if "%ARCHCHOICES%" neq "Select architecture (" @set ARCHCHOICES=%ARCHCHOICES% ,
@if exist "CFG\x86"\ @set ARCHCHOICES=%ARCHCHOICES% x86
@if exist "CFG\x64"\ @if "%ARCHCHOICES%" neq "Select architecture (" @set ARCHCHOICES=%ARCHCHOICES% ,
@if exist "CFG\x64"\ @set ARCHCHOICES=%ARCHCHOICES% x64
@set /P ARCHCONFIG="%ARCHCHOICES% ) : "

@set LANGCHOICES=Select language (
@if exist "CFG\%ARCHCONFIG%\EN"\ @if "%LANGCHOICES%" neq "Select language (" @set LANGCHOICES=%LANGCHOICES% ,
@if exist "CFG\%ARCHCONFIG%\EN"\ @set LANGCHOICES=%LANGCHOICES% EN
@if exist "CFG\%ARCHCONFIG%\FR"\ @if "%LANGCHOICES%" neq "Select language (" @set LANGCHOICES=%LANGCHOICES% ,
@if exist "CFG\%ARCHCONFIG%\FR"\ @set LANGCHOICES=%LANGCHOICES% FR
@set /P LANGCONFIG="%LANGCHOICES% ) : "

@set OSCHOICES=Select OS (
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\2000"\ @if "%OSCHOICES%" neq "Select OS (" @set OSCHOICES=%OSCHOICES% ,
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\2000"\ @set OSCHOICES=%OSCHOICES% 2000
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\XP"\ @if "%OSCHOICES%" neq "Select OS (" @set OSCHOICES=%OSCHOICES% ,
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\XP"\ @set OSCHOICES=%OSCHOICES% XP
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\2003"\ @if "%OSCHOICES%" neq "Select OS (" @set OSCHOICES=%OSCHOICES% ,
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\2003"\ @set OSCHOICES=%OSCHOICES% 2003
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\Vista"\ @if "%OSCHOICES%" neq "Select OS (" @set OSCHOICES=%OSCHOICES% ,
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\Vista"\ @set OSCHOICES=%OSCHOICES% Vista
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\2008"\ @if "%OSCHOICES%" neq "Select OS (" @set OSCHOICES=%OSCHOICES% ,
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\2008"\ @set OSCHOICES=%OSCHOICES% 2008
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\Seven"\ @if "%OSCHOICES%" neq "Select OS (" @set OSCHOICES=%OSCHOICES% ,
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\Seven"\ @set OSCHOICES=%OSCHOICES% Seven
@set /P OSCONFIG="%OSCHOICES% ) : "

@set EDCHOICES=Select edition (
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\Business"\ @if "%EDCHOICES%" neq "Select edition (" @set EDCHOICES=%EDCHOICES% ,
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\Business"\ @set EDCHOICES=%EDCHOICES% Business
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\Professional"\ @if "%EDCHOICES%" neq "Select edition (" @set EDCHOICES=%EDCHOICES% ,
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\Professional"\ @set EDCHOICES=%EDCHOICES% Professional
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\Enterprise"\ @if "%EDCHOICES%" neq "Select edition (" @set EDCHOICES=%EDCHOICES% ,
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\Enterprise"\ @set EDCHOICES=%EDCHOICES% Enterprise
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\Ultimate"\ @if "%EDCHOICES%" neq "Select edition (" @set EDCHOICES=%EDCHOICES% ,
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\Ultimate"\ @set EDCHOICES=%EDCHOICES% Ultimate
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\Professionnel"\ @if "%EDCHOICES%" neq "Select edition (" @set EDCHOICES=%EDCHOICES% ,
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\Professionnel"\ @set EDCHOICES=%EDCHOICES% Professionnel
@set /P EDCONFIG="%EDCHOICES% ) : "

@set SPCHOICES=Select service pack (
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\SP0"\ @if "%SPCHOICES%" neq "Select service pack (" @set SPCHOICES=%SPCHOICES% ,
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\SP0"\ @set SPCHOICES=%SPCHOICES% SP0
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\SP1"\ @if "%SPCHOICES%" neq "Select service pack (" @set SPCHOICES=%SPCHOICES% ,
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\SP1"\ @set SPCHOICES=%SPCHOICES% SP1
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\SP2"\ @if "%SPCHOICES%" neq "Select service pack (" @set SPCHOICES=%SPCHOICES% ,
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\SP2"\ @set SPCHOICES=%SPCHOICES% SP2
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\SP3"\ @if "%SPCHOICES%" neq "Select service pack (" @set SPCHOICES=%SPCHOICES% ,
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\SP3"\ @set SPCHOICES=%SPCHOICES% SP3
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\SP4"\ @if "%SPCHOICES%" neq "Select service pack (" @set SPCHOICES=%SPCHOICES% ,
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\SP4"\ @set SPCHOICES=%SPCHOICES% SP4
@set /P SPCONFIG="%SPCHOICES% ) : "

@set COMPUTERCHOICES=Select computer (
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\%SPCONFIG%\ASUS-P5Q-Pro"\ @if "%COMPUTERCHOICES%" neq "Select computer (" @set COMPUTERCHOICES=%COMPUTERCHOICES% ,
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\%SPCONFIG%\ASUS-P5Q-Pro"\ @set COMPUTERCHOICES=%COMPUTERCHOICES% ASUS-P5Q-Pro
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\%SPCONFIG%\ABIT-KG7"\ @if "%COMPUTERCHOICES%" neq "Select computer (" @set COMPUTERCHOICES=%COMPUTERCHOICES% ,
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\%SPCONFIG%\ABIT-KG7"\ @set COMPUTERCHOICES=%COMPUTERCHOICES% ABIT-KG7
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\%SPCONFIG%\HP-Brio"\ @if "%COMPUTERCHOICES%" neq "Select computer (" @set COMPUTERCHOICES=%COMPUTERCHOICES% ,
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\%SPCONFIG%\HP-Brio"\ @set COMPUTERCHOICES=%COMPUTERCHOICES% HP-Brio
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\%SPCONFIG%\Thinkpad-R51"\ @if "%COMPUTERCHOICES%" neq "Select computer (" @set COMPUTERCHOICES=%COMPUTERCHOICES% ,
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\%SPCONFIG%\Thinkpad-R51"\ @set COMPUTERCHOICES=%COMPUTERCHOICES% Thinkpad-R51
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\%SPCONFIG%\eeePC-901"\ @if "%COMPUTERCHOICES%" neq "Select computer (" @set COMPUTERCHOICES=%COMPUTERCHOICES% ,
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\%SPCONFIG%\eeePC-901"\ @set COMPUTERCHOICES=%COMPUTERCHOICES% eeePC-901
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\%SPCONFIG%\eeePC-T91"\ @if "%COMPUTERCHOICES%" neq "Select computer (" @set COMPUTERCHOICES=%COMPUTERCHOICES% ,
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\%SPCONFIG%\eeePC-T91"\ @set COMPUTERCHOICES=%COMPUTERCHOICES% eeePC-T91
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\%SPCONFIG%\eeePC-T91 (after recovery)"\ @if "%COMPUTERCHOICES%" neq "Select computer (" @set COMPUTERCHOICES=%COMPUTERCHOICES% ,
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\%SPCONFIG%\eeePC-T91 (after recovery)"\ @set COMPUTERCHOICES=%COMPUTERCHOICES% eeePC-T91 (after recovery)
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\%SPCONFIG%\eeePC-T91MT"\ @if "%COMPUTERCHOICES%" neq "Select computer (" @set COMPUTERCHOICES=%COMPUTERCHOICES% ,
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\%SPCONFIG%\eeePC-T91MT"\ @set COMPUTERCHOICES=%COMPUTERCHOICES% eeePC-T91MT
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\%SPCONFIG%\eeePC-T91MT (after recovery)"\ @if "%COMPUTERCHOICES%" neq "Select computer (" @set COMPUTERCHOICES=%COMPUTERCHOICES% ,
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\%SPCONFIG%\eeePC-T91MT (after recovery)"\ @set COMPUTERCHOICES=%COMPUTERCHOICES% eeePC-T91MT (after recovery)
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\%SPCONFIG%\CPU-1472"\ @if "%COMPUTERCHOICES%" neq "Select computer (" @set COMPUTERCHOICES=%COMPUTERCHOICES% ,
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\%SPCONFIG%\CPU-1472"\ @set COMPUTERCHOICES=%COMPUTERCHOICES% CPU-1472
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\%SPCONFIG%\MSM945"\ @if "%COMPUTERCHOICES%" neq "Select computer (" @set COMPUTERCHOICES=%COMPUTERCHOICES% ,
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\%SPCONFIG%\MSM945"\ @set COMPUTERCHOICES=%COMPUTERCHOICES% MSM945
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\%SPCONFIG%\HPNW09"\ @if "%COMPUTERCHOICES%" neq "Select computer (" @set COMPUTERCHOICES=%COMPUTERCHOICES% ,
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\%SPCONFIG%\HPNW09"\ @set COMPUTERCHOICES=%COMPUTERCHOICES% HPNW09
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\%SPCONFIG%\ThinkPad-W700-1"\ @if "%COMPUTERCHOICES%" neq "Select computer (" @set COMPUTERCHOICES=%COMPUTERCHOICES% ,
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\%SPCONFIG%\ThinkPad-W700-1"\ @set COMPUTERCHOICES=%COMPUTERCHOICES% ThinkPad-W700-1
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\%SPCONFIG%\ThinkPad-W700-1 (after recovery)"\ @if "%COMPUTERCHOICES%" neq "Select computer (" @set COMPUTERCHOICES=%COMPUTERCHOICES% ,
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\%SPCONFIG%\ThinkPad-W700-1 (after recovery)"\ @set COMPUTERCHOICES=%COMPUTERCHOICES% ThinkPad-W700-1 (after recovery)
@set /P COMPUTERCONFIG="%COMPUTERCHOICES% ) : "

@set /P OSSETUPROOT="Select directory containing OS setup files : "
@set /P DESTROOT="Select destination directory : "
@set /P DVDNAME="Type first DVD name (leave empty if you do not wish to generate a bootable DVD) : "

@echo Copying files...

@FOR %%j IN (1 2 3 4 5) DO @(
@md "%DESTROOT%\DVD%%j"\
)

@if exist "%OSSETUPROOT%"\ @start /w robocopy0 "%OSSETUPROOT%" "%DESTROOT%\DVD1"\

@FOR %%j IN (1 2 3 4 5) DO @(
@if exist "CFG\Common\DVD%%j"\ @start /w robocopy0 "CFG\Common\DVD%%j" "%DESTROOT%\DVD%%j"\
@if exist "CFG\%ARCHCONFIG%\Common\DVD%%j"\ @start /w robocopy0 "CFG\%ARCHCONFIG%\Common\DVD%%j" "%DESTROOT%\DVD%%j"\
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\Common\DVD%%j"\ @start /w robocopy0 "CFG\%ARCHCONFIG%\%LANGCONFIG%\Common\DVD%%j" "%DESTROOT%\DVD%%j"\
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\Common\DVD%%j"\ @start /w robocopy0 "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\Common\DVD%%j" "%DESTROOT%\DVD%%j"\
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\Common\DVD%%j"\ @start /w robocopy0 "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\Common\DVD%%j" "%DESTROOT%\DVD%%j"\
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\%SPCONFIG%\Common\DVD%%j"\ @start /w robocopy0 "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\%SPCONFIG%\Common\DVD%%j" "%DESTROOT%\DVD%%j"\
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\%SPCONFIG%\%COMPUTERCONFIG%\DVD%%j"\ @start /w robocopy0 "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\%SPCONFIG%\%COMPUTERCONFIG%\DVD%%j" "%DESTROOT%\DVD%%j"\
@FOR %%i IN (1 2 3 4 5) DO @(
@if exist "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\%SPCONFIG%\%COMPUTERCONFIG%\DVD%%j\CMPNENTS\CMPNENTS%%i.bat" @start /w GenCMPNENTSList.exe /dvd %%j /f "CFG\%ARCHCONFIG%\%LANGCONFIG%\%OSCONFIG%\%EDCONFIG%\%SPCONFIG%\%COMPUTERCONFIG%\DVD%%j\CMPNENTS\CMPNENTS%%i.bat"
@if exist CopyCMPNENTS%%i.bat (@call CopyCMPNENTS%%i.bat %DESTROOT% & del /f /q CopyCMPNENTS%%i.bat)
)
)

@if not "%DVDNAME%"=="" (
@echo Generating bootable DVD image...
@if %OSCONFIG%==2000 @goto ISONT5
@if %OSCONFIG%==XP @goto ISONT5
@if %OSCONFIG%==2003 @goto ISONT5
@if %OSCONFIG%==Vista @goto ISONT6
@if %OSCONFIG%==2008 @goto ISONT6
@if %OSCONFIG%==Seven @goto ISONT6
@goto ERROR

:ISONT5
@if %ARCHCONFIG%==x86 @move /Y %DESTROOT%\DVD1\I386\$OEM$ %DESTROOT%\DVD1 | rem
@if %ARCHCONFIG%==x64 @move /Y %DESTROOT%\DVD1\AMD64\$OEM$ %DESTROOT%\DVD1 | rem
@start /w oscdimg "%DESTROOT%\DVD1" "%DESTROOT%\%DVDNAME%.ISO" -l"%DVDNAME%" -h -b"%DESTROOT%\DVD1\BOOT.IMA" -n -m -d
@if %ARCHCONFIG%==x86 @move /Y %DESTROOT%\DVD1\$OEM$ %DESTROOT%\DVD1\I386 | rem
@if %ARCHCONFIG%==x64 @move /Y %DESTROOT%\DVD1\$OEM$ %DESTROOT%\DVD1\AMD64 | rem
@goto END

:ISONT6
@start /w oscdimg "%DESTROOT%\DVD1" "%DESTROOT%\%DVDNAME%.ISO" -l"%DVDNAME%" -h -b"%DESTROOT%\DVD1\boot\etfsboot.com" -u2
@goto END
)

:END
@echo.
@echo Note that if you do not want to burn all DVDs, you can copy their content in a single folder called SETUPROOT and placed at the root of an accessible (during installation) hard drive partition.
@echo.

@pause
@exit

:ERROR
@echo.
@echo An error occured.
@echo.

@pause
@exit
