File: MakeIsoRedirect.cmd
setlocal
if '%LogDir%' == '' set LogDir=%temp%
if '%DateAndTime%' == '' for /F "tokens=1,2,3,4 delims=/ " %%i in ('date /t') do set today=%%l%%j%%k
if '%DateAndTime%' == '' for /F "tokens=1,2 delims=: " %%i in ('time /t') do set DateAndTime=%today%_%%i%%j
if '%ErrorLog%' == '' set ErrorLog=%LogDir%\ErrorLog__%DateAndTime%.txt
rd /s /q C:\myprojects\Diagnostics\PE\Step1
if errorlevel 1 goto InstallFaied
rd /s /q C:\myprojects\Diagnostics\PE\Step2
if errorlevel 1 goto InstallFaied
mkdir C:\myprojects\Diagnostics\PE\Step2
if errorlevel 1 goto InstallFaied
if /i not '%1' == '-xp' goto :Standard
mkdir C:\myprojects\Diagnostics\PE\Step1
if errorlevel 1 goto InstallFaied
imagex /capture C:\myprojects\Diagnostics\Xp\SP3 C:\myprojects\Diagnostics\PE\Step1\xpsp3.wim "xp sp3" /verify /compress maximum
if errorlevel 1 goto InstallFaied
goto :InstallOK
:Standard
cmd /c "copype.cmd x86 C:\myprojects\Diagnostics\PE\Step1"
if errorlevel 1 goto InstallFaied
rename C:\myprojects\Diagnostics\PE\Step1\ISO\boot\bootfix.bin bootfix.disabled
if errorlevel 1 goto InstallFaied
imagex /mountrw C:\myprojects\Diagnostics\PE\Step1\winpe.wim 1 C:\myprojects\Diagnostics\PE\Step2
if errorlevel 1 goto InstallFaied
peimg /install=*HTA* C:\myprojects\Diagnostics\PE\Step2\Windows
if errorlevel 1 goto InstallFaied
peimg /install=*MDAC* C:\myprojects\Diagnostics\PE\Step2\Windows
if errorlevel 1 goto InstallFaied
peimg /install=*scripting* C:\myprojects\Diagnostics\PE\Step2\Windows
if errorlevel 1 goto InstallFaied
peimg /install=*WMI* C:\myprojects\Diagnostics\PE\Step2\Windows
if errorlevel 1 goto InstallFaied
peimg /install=*XML* C:\myprojects\Diagnostics\PE\Step2\Windows
if errorlevel 1 goto InstallFaied
Rem add DriveImg, use procmon and look for access denied
rem peimg /inf="C:\myprojects\Diagnostics\DriveImageXML\dixml.inf"
/image="C:\myprojects\Diagnostics\PE\Step2\Windows"
rem if errorlevel 1 goto InstallFaied
goto :EOF
xcopy /d /s /e /q "C:\myprojects\Diagnostics\SysInternals_pe\*.*" "C:\myprojects\Diagnostics\PE\Step2\Program files\SysInternals\*.*"
if errorlevel 1 goto InstallFaied
xcopy /d /s /e /q C:\myprojects\Diagnostics\Bart\BART-Avast\*.* "C:\myprojects\Diagnostics\PE\Step2\Program files\BART-Avast\*.*"
if errorlevel 1 goto InstallFaied
xcopy /d /s /e /q C:\myprojects\Diagnostics\TextPad\*.* "C:\myprojects\Diagnostics\PE\Step2\Program files\TextPad\*.*"
if errorlevel 1 goto InstallFaied
xcopy /d /s /e /q C:\myprojects\Diagnostics\K-Meleon\*.* "C:\myprojects\Diagnostics\PE\Step2\Program files\K-Meleon\*.*"
if errorlevel 1 goto InstallFaied
xcopy /d /s /e /q "C:\myprojects\Diagnostics\Zip\*.*" "C:\myprojects\Diagnostics\PE\Step2\Program files\Zip\*.*"
if errorlevel 1 goto InstallFaied
rem does not work on pe
rem xcopy /d /s /e /q "C:\myprojects\Diagnostics\DriveImageXML\*.*" "C:\myprojects\Diagnostics\PE\Step2\Program files\DriveImageXML\*.*"
if errorlevel 1 goto InstallFaied
xcopy /d /s /e /q "C:\myprojects\Diagnostics\Scripts\*.*" "C:\myprojects\Diagnostics\PE\Step2\Program files\Scripts\*.*"
if errorlevel 1 goto InstallFaied
xcopy /d /s /e /q "C:\myprojects\Diagnostics\DriveImageXML\*.* "C:\myprojects\Diagnostics\PE\Step2\Program files\DriveImageXML\*.*"
if errorlevel 1 goto InstallFaied
peimg /f /prep C:\myprojects\Diagnostics\PE\Step2\Windows
if errorlevel 1 goto InstallFaied
imagex /unmount C:\myprojects\Diagnostics\PE\Step2 /commit
if errorlevel 1 goto InstallFaied
copy C:\myprojects\Diagnostics\PE\Step1\winpe.wim C:\myprojects\Diagnostics\PE\Step1\ISO\sources\boot.wim
if errorlevel 1 goto InstallFaied
oscdimg -n -bC:\myprojects\Diagnostics\PE\Step1\etfsboot.com C:\myprojects\Diagnostics\PE\Step1\ISO C:\myprojects\Diagnostics\PE\ISO\Boot.iso
if errorlevel 1 goto InstallFaied
:InstallOK
echo. > CON
echo. > CON
echo MakeIso completed ok. > CON
echo. > CON
echo. > CON
goto :EOF
:InstallFaied
rem must unmount otherwise image is locked
imagex /unmount C:\myprojects\Diagnostics\PE\Step2 /commit
TYpe %ErrorLog%
echo. > CON
echo. > CON
echo MakeIso completed with errors. > CON
echo. > CON
echo. > CON
TYpe %ErrorLog% > CON
goto :EOF
endlocal