!BAT
# load getstr batch file into memory
insmod /%grub%/getstr.g4b

getstr.g4b $$STRbLR1
echo -e %STR%
#echo XP INSTALL - STEP 2 LowRAM (only use for Low RAM Systems <512MB)
#echo ===============================================================
echo
if not "%XPISO%"=="" set ISO=%XPISO% && goto :skpxpi
# list all files in the folder so the user can pick one
/%grub%/PickaFile.g4b %MFOLDER% .ISO
echo
# check if user aborted
if "%CHOSEN%"==""  echo Aborting... && /%grub%/configX.g4b (bd)/%grub%/menuWinInstall.lst
set ISO=%CHOSEN%
:skpxpi

debug off
map --mem (bd)/%grub%/NewWinVBlock.ima.gz (fd0)
map --mem (bd)/%grub%/NewWinVBlock.ima.gz (fd1)
map %MFOLDER%/%ISO% (0xff)

#map USb drive to topmost drive slot that is free
map (hd0) ()
map (hd1) (hd0)

#set /a HDCNT=*0x475 & 0xff - 1 > nul
#set topmap=(hd%HDCNT%)
clear
#if %HDCNT%>=1 map (hd0) %topmap% > nul && map (hd1) (hd0) > nul && echo Mapping (hd0) to %topmap% and (hd1) to (hd0)
#if %HDCNT%>=2 map (hd2) (hd1) > nul && if %HDCNT%>=3 map (hd3) (hd2) > nul && if %HDCNT%>=4 map (hd4) (hd3) > nul  && if %HDCNT%>=5 map (hd5) (hd4) > nul && if %HDCNT%>=6 map (hd6) (hd5) > nul && if %HDCNT%>=7 map (hd7) (hd6) > nul && if %HDCNT%>=8 map (hd8) (hd7) > nul

map --hook > nul

map --rd-size=2048
map --mem (rd)+4 (0x55)
map --rehook

write (0x55) #!GRUB4DOS\x00v=1\x00%MFOLDER:~1%/%ISO%\x00\xff\x00

#cat --hex --length=300 (0x55)+1 && pause

root (hd0,0) > nul || root (hd0,1) > nul || root (hd0,2) > nul || rootnoverify (hd0,0) > nul

getstr.g4b $$STRbLR2
echo -e %STR%
#echo DO NOT REMOVE THE USB DRIVE! - rebooting from hard disk...
echo
getstr.g4b $$STRb021
set /u /p:5 ask=%STR%
#set /u /p:5 ask= SPACEBAR=Pause, ENTER=Start now - STARTING IN 5 SECONDS...
if "%ask%"=="D" commandline
if "%ask%"=="C" commandline
if "%ask%"=="A" map --unmap=0:0xff > nul && map --unhook > nul && root (bd) > nul && /%grub%/configX.g4b (bd)/%grub%/menuWinInstall.lst

chainloader (hd0)+1
exit

