!BAT
:GETXPISO

# load module
insmod /%grub%/getstr.g4b

if exist CD echo Sorry - this won't work from a CD! && pause && exit

clear
echo
getstr.g4b $$STRT001
echo -e %STR%

# find the ISO folder by looking for a marker file
debug off
# list all files in the folder so the user can pick one
/%grub%/PickaFile.g4b %MYPATH% .ISO
echo
# check if user aborted
if "%CHOSEN%"==""  echo Aborting... && /%grub%/configX.g4b (bd)/%grub%/menuWinInstall.lst
if "%CHOSEN%"=="0"  echo Aborting... && /%grub%/configX.g4b (bd)/%grub%/menuWinInstall.lst
set ISO=%CHOSEN%

# check if user entered a valid filename with no ISO extension!
if not exist %MYPATH%/"%CHOSEN% echo -e Cannot find %MYPATH%/"%CHOSEN% !!!\n && pause --wait=3 && goto :GETXPISO
set MYISO=%CHOSEN%

:GETPE
clear
echo XP ISO=%MYISO%
echo
echo
# Ask user which WinPE iso they want (name is converted to uppercase as /u is specified)
set ask=
echo
getstr.g4b $$STRT002
call echo -e %STR%

::echo    NOW CHOOSE A WINPE 'Helper' ISO
::echo -e ===============================
::echo We need to temporarily boot to WinPE in order to run WINNT32.EXE
::echo Please specify a WinPE or Windows Install ISO (must be Vista or later, 32-bit)
echo
echo -e \x20 1=\\_ISO\\WINDOWS\\XP
echo -e \x20 2=\\_ISO\\WINDOWS\\VISTA
echo -e \x20 3=\\_ISO\\WINDOWS\\SVR2K8R2
echo -e \x20 4=\\_ISO\\WINDOWS\\SVR2012
echo -e \x20 5=\\_ISO\\WINDOWS\\WIN7
echo -e \x20 6=\\_ISO\\WINDOWS\\WIN8
echo -e \x20 7=\\_ISO\\WINDOWS\\SVR2012
echo -e \x20 8=\\_ISO\\WINDOWS\\WIN10
echo -e \x20 9=\\_ISO\\WINPE
echo -e \x2010=\\_ISO\\MAINMENU
echo -e \x2011=\\_ISO\\MAINMENU\\WINDOWS


echo
set ask=
getstr.g4b $$STRT003
set /p ask=%STR%
if "%ask%"=="" echo && /%grub%/configX.g4b (bd)/%grub%/menuWinInstall.lst
if "%ask%"=="0" goto :GETPE
if "%ask%"=="1" set PEPATH=/_ISO/WINDOWS/XP
if "%ask%"=="2" set PEPATH=/_ISO/WINDOWS/VISTA
if "%ask%"=="3" set PEPATH=/_ISO/WINDOWS/SVR2K8R2
if "%ask%"=="4" set PEPATH=/_ISO/WINDOWS/SVR2012
if "%ask%"=="5" set PEPATH=/_ISO/WINDOWS/WIN7
if "%ask%"=="6" set PEPATH=/_ISO/WINDOWS/WIN8
if "%ask%"=="7" set PEPATH=/_ISO/WINDOWS/SVR2012
if "%ask%"=="8" set PEPATH=/_ISO/WINDOWS/WIN10
if "%ask%"=="9" set PEPATH=/_ISO/WINPE
if "%ask%"=="10" set PEPATH=/_ISO/MAINMENU
if "%ask%"=="11" set PEPATH=/_ISO/MAINMENU/WINDOWS
set /a ask=%ask%+0 > nul
echo
if "%ask%"=="" /%grub%/configX.g4b (bd)/%grub%/menuWinInstall.lst
if %ask%>=12 pause --wait=3 "%ask%" is an INVALID ENTRY!  && goto :GETPE
echo
echo

getstr.g4b $$STRT004
call echo -e %STR%

#echo    NOW CHOOSE A WinPE 'Helper' ISO
#echo -e ===============================
#echo From %PEPATH%
# list all files in the folder so the user can pick one
/%grub%/PickaFile.g4b  %PEPATH% .ISO
echo
# check if user aborted
if "%CHOSEN%"=="" echo Aborting... && /%grub%/configX.g4b (bd)/%grub%/menuWinInstall.lst
if "%CHOSEN%"=="0" echo Aborting... && /%grub%/configX.g4b (bd)/%grub%/menuWinInstall.lst
set MYISOPE=%CHOSEN%

clear
echo XP ISO=%MYISO%     WinPE ISO=%MYISOPE%
echo
# Ask user what size they want
set ask=

getstr.g4b $$STRT005
call echo -e %STR%
getstr.g4b $$STRTA05
call echo -e %STR%
#echo HARD DISK PARTITION SIZE
#echo -e ========================
#echo
#echo Easy2Boot can wipe the hard disk and create a new partition
#echo or can format an existing partition
#echo or can install to an existing partition.
#echo
#echo Please set a default size for now.
#echo You will be asked if you want to format the hard disk later...
echo
getstr.g4b $$STRTB05
set /p /u ask=%STR%
if "%ask%"=="" echo && /%grub%/configX.g4b (bd)/%grub%/menuWinInstall.lst
set /a PTN1=%ask%

:UNAT
clear
echo XP ISO=%MYISO%     WinPE ISO=%MYISOPE%     PARTITION=%PTN1%MB (0=MAX)
echo
# Ask user what unattend.txt
echo
getstr.g4b $$STRT006
call echo -e %STR%
#echo CHOOSE AN UNATTEND.TXT FILE
#echo -e ===========================
#echo From %MYPATH%
echo
# list all files in the folder so the user can pick one
set ZZ=No unattend.xml (manual install)
/%grub%/PickaFile.g4b  %MYPATH% .txt
echo
if "%CHOSEN%"=="" set CHOSEN=NONE
if "%CHOSEN%"=="0" set CHOSEN=NONE
set UNAT=%CHOSEN%
set PUNAT=
if not "%UNAT%"=="NONE" set PUNAT=%WMYPATH%\\%UNAT%
echo UNATTEND FILE=%UNAT%

:DOIT
echo Copying auwinnt.xml to \AutoUnattend.xml and \Unattend.xml...
# if extra USB Flash drive use Autounattend.xml on it - must have WINHELPER.USB file on it!
echo
root (bd) > nul
errorcheck off
ls /AutoUnattend.xml > nul || echo -e WARNING: No \\AutoUnattend.xml found on (bd) - Install may not work!! && pause --wait=3
dd if=(bd)/_ISO/e2b/firadisk/auwinnt.xml of=()/AutoUnattend.xml > nul
ls /Unattend.xml > nul || echo -e WARNING: No \\Unattend.xml found on (bd) - Install will not work! && pause --wait=3
dd if=(bd)/_ISO/e2b/firadisk/auwinnt.xml of=()/Unattend.xml > nul

ls (hd0,0)/WINHELPER.USB > nul
ls (hd1,0)/WINHELPER.USB > nul
root (hd2,0) > nul
ls (hd2,0)/WINHELPER.USB > nul


#findX --set-root --devices=h /WINHELPER.USB > nul
set WH=
if exist (hd1,0)/WINHELPER.USB root (hd1,0) > nul && set WH=1
if "%WH%"=="" if exist (hd0,0)/WINHELPER.USB root (hd0,0) > nul && set WH=1
if "%WH%"=="" if exist (hd2,0)/WINHELPER.USB root (hd2,0) > nul && set WH=1
if "%WH%"=="" if exist (hd3,0)/WINHELPER.USB root (hd3,0) > nul && set WH=1
if "%WH%"=="" if exist (hd4,0)/WINHELPER.USB root (hd4,0) > nul && set WH=1
if "%WH%"=="" if exist (hd5,0)/WINHELPER.USB root (hd5,0) > nul && set WH=1
if "%WH%"=="" if exist (hd6,0)/WINHELPER.USB root (hd6,0) > nul && set WH=1
if "%WH%"=="" if exist (hd7,0)/WINHELPER.USB root (hd7,0) > nul && set WH=1
if "%WH%"=="" if exist (hd8,0)/WINHELPER.USB root (hd8,0) > nul && set WH=1
if "%WH%"=="" if exist (hd9,0)/WINHELPER.USB root (hd9,0) > nul && set WH=1
errorcheck on
debug 0
if not "%WH%"=="1" goto :pp

ls /AutoUnattend.xml > nul || echo -e WARNING: No \\AutoUnattend.xml found on Helper USB - Install may not work!! && pause --wait=3
dd if=(bd)/_ISO/e2b/firadisk/auwinnt.xml of=()/AutoUnattend.xml > nul
ls /Unattend.xml > nul || echo -e WARNING: No \\Unattend.xml found on Helper USB - Install will not work! && pause --wait=3
dd if=(bd)/_ISO/e2b/firadisk/auwinnt.xml of=()/Unattend.xml > nul

:pp
root (bd) > nul
# fill (rd) with 0's , 0x82d0 is rd-base mem address, Fn24 is memset - fill memory  <addr> <string> <size>
map (md)0x300+200 (rd) > nul ;; read 0x82d0  > nul ;; call Fn.24  %@retval% 0x20  102400  > nul  
dd if=(rd)+1 of=()/_ISO/e2b/firadisk/ISONAME.CMD > nul
write ()/_ISO/e2b/firadisk/ISONAME.CMD SET \"MYISO=%WMYPATH%\\%MYISO%\"\r\nSET PTN1=%PTN1%\r\nSET UNAT=%PUNAT%\r\n\0\x1a\0
echo
echo
echo Using these settings...
cat ()/_ISO/e2b/firadisk/ISONAME.CMD
echo
getstr.g4b $$STRPKEY
pause %STR%


map %PEPATH%/%MYISOPE% (0xff)
if not exist CD map (hd0) (hd1)
if not exist CD map (hd1) (hd0)
map --hook > nul
chainloader (0xff)/bootmgr || chainloader (0xff)

#get rid of 'press any key' prompt
cat --locate=BOOTFIX.BIN --number=1 --replace=XXX (0xff)+0x1000

