echo %@time% menu.lst START > (md)0x9999+3

# --------   DO NOT CHANGE THIS FILE - use \_ISO\MyE2B.cfg to change the settings  ------

# move variables to different location (must use 2014-10 or later grub4dos) - prevents ?_BOOT from getting corrupted by bad BIOSes on disk error  0x280,0000 = 40MB
# only use if bad bios!
#write 0x307ff4 0x2800000 && set ?_BOOT=%?_BOOT% && set grub=%grub%

# turn off cursor and clear screen
call Fn.70 0 ;; clear
read 0x8278 > nul
set v=%@retval%
checkrange 20150209:-1 read 0x8278 > nul || echo -e \n\n$[0104]WARNING: Grub4dos \\grldr file is an old version \[%v%\].\n\nE2B may not work correctly (copy all E2B files to this drive to update it).\nGrub4dos version must be 2015-02-09 or later!\n\n && pause Press a key to continue using old version...
set v=

set NOHD1=
geometry (hd1) > nul || set NOHD1=1
if exist NOHD1 if not exist _BOOT echo -e \n\n$[0105]INFORMATION: System Hard Disk (hd1) not detected by BIOS!\nSome payload files may not work correctly.\n\n && debug -1 && pause --wait=2
set NOHD1=
debug normal

# save ?_BOOT as _BOOT in case it gets corrupted by bad BIOS
if "%_BOOT%"=="" set _BOOT=%?_BOOT%
set * && set grub=%grub% && set DONEMENU=%DONEMENU% && set DL=%DL% && set LANG=%LANG% && set GRUB_DUN=%GRUB_DUN% && set _BOOT=%_BOOT%

#uninstall hotkey and lose all preset definitions
/%grub%/hotkey -u > nul 

# _BOOT/?_BOOT = disk&partition that contained the file \grldr that was used to boot to grub4dos, e.g. (hd0,0)   - note: this is NOT the same as (bd) which is set to whatever partition contained the menu.lst file.
#if we booted as floppy instead of hd then stop!
if "%_BOOT:~0,2%"=="(f" pause ERROR: This drive booted as a floppy disk - please change BIOS settings to boot as a hard disk or read E2B FAQ! && commandline

map --unhook > nul
map --unmap=0:0xff > nul
root (bd)/ > nul

#Are we booting from a CD?
set CD= && if "%_BOOT%"=="(cd)" set CD=1

# find grub folder...
if not exist /%grub%/E2B_GRUB.txt set grub=
if not exist grub if exist /_ISO/e2b/grub/E2B_GRUB.txt set grub=_ISO/e2b/grub
if not exist grub if exist /grub/E2B_GRUB.txt set grub=grub
if not exist grub if exist /e2b/grub/E2B_GRUB.txt set grub=e2b/grub
if not exist grub if exist /_ISO/grub/E2B_GRUB.txt set grub=_ISO/grub
# try to find grub folder anywhere in system
if not exist grub echo -n -e $[0104] WARNING: CAN'T FIND E2B 'grub' FOLDER && pause --wait=2 Looking on all partitions...
if not exist grub find --set-root /_ISO/e2b/grub/E2B_GRUB.txt > nul && set grub=_ISO/e2b/grub
if not exist grub echo EASY2BOOT - SORRY, CAN'T FIND E2B_GRUB.txt file (please edit \menu.lst file to set grub variable)! && pause && commandline


#get E2B DEVICE DISK - e.g. hd0 or hd3 - for use with partnew command
set E2BDEV=%_BOOT:~1,4%
if "%E2BDEV:~3,1%"=="," set E2BDEV=%E2BDEV:~0,3%
#if _BOOT not cd or hd then assume hd0 (_BOOT corrupted!)
if not "%E2BDEV:~0,2%"=="hd" && if not "%E2BDEV:~0,2%"=="cd" set E2BDEV=hd0
if "%E2BDEV%"=="cd)" set E2BDEV=cd
set ask=
if not "%E2BDEV%"=="hd0" if "%E2BDEV:~0,2%"=="hd" echo -e $[0104] WARNING: The Easy2Boot drive has been detected as %E2BDEV%\n (partition %E2BDEV%,3 will be changed if you continue)
if not "%E2BDEV%"=="hd0" if "%E2BDEV:~0,2%"=="hd" set /p ask=Press C and then ENTER to continue : 
if not "%E2BDEV%"=="hd0" if "%E2BDEV:~0,2%"=="hd" if /i not "%ask%"=="C" commandline
set ask=


#check hd0 is OK to modify partitions on, otherwise partnew could wipe the internal hard disk partition!
set PN=
if not exist CD if exist (hd0,0)/%grub%/E2B_GRUB.txt  set PN=1
if not exist PN if not exist CD if exist (hd0,1)/%grub%/E2B_GRUB.txt  set PN=1
if not exist PN if not exist CD if exist (hd0,4)/%grub%/E2B_GRUB.txt  set PN=1
if not exist PN if not exist CD if exist (hd0,5)/%grub%/E2B_GRUB.txt  set PN=1
if not exist PN if not exist CD if exist (hd0,6)/%grub%/E2B_GRUB.txt  set PN=1
if not exist PN if not exist CD if exist (hd0,7)/%grub%/E2B_GRUB.txt  set PN=1
if not exist PN if not exist CD if exist (hd0,8)/%grub%/E2B_GRUB.txt  set PN=1
if not exist PN if not exist CD if exist (hd0,9)/%grub%/E2B_GRUB.txt  set PN=1
if not exist PN if not exist CD if exist (hd0,0)/WINHELPER.USB  set PN=1
if not exist PN if not exist CD && find && root && echo grub=%grub%  _BOOT=%_BOOT%  E2BDEV=%E2BDEV% && ls (%E2BDEV%,0)/%grub%/E2B_GRUB.txt && echo && blocklist (%E2BDEV%,0)/%grub%/E2B_GRUB.txt && echo && echo (hd0,0) && ls (hd0,0) && echo && echo && pause  ERROR: hd0 does not seem to be an E2B or WINHELPER drive! && commandline
set PN=

# old %xxx% colour variables no longer supported
#set black=0 && set blue=1 &&  set green=2 && set cyan=3 &&   set red=4 &&   set magenta=5 && set brown=6 &&    set lgray=7  && set lgrey=7
#set dgrey=8 && set dgray=8 && set lblue=9 && set lgreen=A && set lcyan=B && set lred=C    && set lmagenta=D && set yellow=E && set white=F

# call config file to get variables!
echo %@time% menu.lst Loading E2B.cfg >> (md)0x9999+3
call /%grub%/E2B.cfg || echo /%grub%/E2B.cfg is MISSING! && pause
#call users MyE2B.cfg
set MYE2B=
echo %@time% menu.lst Start loading \_ISO\MyE2B.cfg >> (md)0x9999+3
if exist /_ISO/MyE2B.cfg  set MYE2B=1 && call /_ISO/MyE2B.cfg
echo %@time% menu.lst Finished loading \_ISO\MyE2B.cfg >> (md)0x9999+3
#clear old variables
set black= && set blue= &&  set green= && set cyan= &&   set red= &&   set magenta= && set brown= &&    set lgray= &&  set lgrey=
set dgrey= && set dgray= && set lblue= && set lgreen= && set lcyan= && set lred= &&    set lmagenta= && set yellow= && set white=
# check if user trying to use old variables
if exist HDG_WIN set HDG_WIN= && set HDGE=1
if exist HDG_VISTA set HDG_VISTA= && set HDGE=1
if exist HDG_2K8 set HDG_2K8= && set HDGE=1
if exist HDG_7 set HDG_7= && set HDGE=1
if exist HDG_8 set HDG_8= && set HDGE=1
if exist HDG_2012 set HDG_2012= && set HDGE=1
if exist HDG_AUTO set HDG_AUTO= && set HDGE=1
if exist HDRAUTO set HDRAUTO= && set HDGE=1
if exist HDRAUTOH set HDRAUTOH= && set HDGE=1
if exist HDGE pause ERROR: Sorry, HDG_xxxx and HDRAUTOx variables are no longer supported in MyE2B.cfg file
set HDGE=

#The clear fills the screen so the bitmap is displayed if call Fn.70 3 is used
clear
# display booting message if redirp is not set
echo Booting Easy2Boot %VER% - please wait...  %redirp%
if exist MYE2B echo Using settings in /_ISO/MyE2B.CFG %redirp%
set MYE2B=
set B64=

#set language folder and call language menu.lst if it exists
if "%LANG%"=="" set LANG=ENG
if "%DL%"=="" if exist ()/_ISO/Menu.lst set DL=1 && configfile ()/_ISO/Menu.lst
if "%DL%"=="" if exist ()/%grub%/%LANG%/Menu.lst set DL=1 && configfile ()/%grub%/%LANG%/Menu.lst
# check language folder is valid
#\_ISO\STRINGS.txt overrides everything!
set STR=
set STRtemp=
if exist /_ISO/STRINGS.txt set STR=/_ISO/STRINGS.txt
if not exist STR if not exist /%grub%/%LANG%/STRINGS.txt set STRtemp=1
if "%STRtemp%"=="1" pause ERROR: /%grub%/%LANG%/STRINGS.txt does not exist!
if "%STRtemp%"=="1" set LANG=ENG && pause Resetting language to ENG
if "%STRtemp%"=="1" if not exist /%grub%/%LANG%/STRINGS.txt pause ERROR: /%grub%/%LANG%/STRINGS.txt does not exist!
if "%STR%"=="" set STR=/%grub%/%LANG%/STRINGS.txt
:: get strings into memory
cat %STR% > (md)0x880+0x80 && echo Using strings from %STR% file %redirp%
if "%STR%"=="/_ISO/STRINGS.txt" echo -e $[0106]WARNING: USE %STR% FOR TESTING ONLY!
set STR=
set STRtemp=
# Always use ENG as backup in case some strings missing from old language files
if not "%LANG%"=="ENG" if not exist /_ISO/STRINGS.txt cat /%grub%/ENG/STRINGS.txt >> (md)0x880+0x80
if exist /_ISO/STRINGS.txt cat /%grub%/ENG/STRINGS.txt >> (md)0x880+0x80

#clear unused variables
set DL=



#initialise memory areas so they are not confused by grub4dos as compressed files!
echo fffffffffffffff > (md)0x800+1
echo fffffffffffffff > (md)0x220+1
echo fffffffffffffff > (md)0x3000+1
echo fffffffffffffff > (md)0x6000+1
echo fffffffffffffff > (md)0xA000+1

# Display BIOS date
call Fn.0 0 0xFFFF5 | echo BIOS DATE = %redir%

echo %@time% menu.lst Start CheckAccess >> (md)0x9999+3
# Warn if buggy BIOS!
if exist CHECKBIOS call /%grub%/CheckAccess.g4b
set CHECKBIOS=
echo %@time% menu.lst Finish CheckAccess >> (md)0x9999+3

# check if we are using grub4dos 0.4.6 - if GRUB_USB=Y then switch to 0.4.6 and initialise USB driver - GRUB_DUN means we have done the usb --init command
set GV=
cat --locate="4DOS 0.4.6" (md)0x200+0x90 > nul && set GV=046 && echo GRUB4DOS 0.4.6 DETECTED %redirp%
cat --locate="4DOS 0.4.5" (md)0x200+0x90 > nul && echo GRUB4DOS 0.4.5 DETECTED %redirp%
if "%GRUB_USB%"=="Y" if "%GV%"=="" if exist  /%grub%/grldr_046 pause --wait=2 Switching to grub4dos 0.4.6 instead... && chainloader /%grub%/grldr_046 > nul && boot
if "%GRUB_USB%"=="Y" if "%GV%"=="046" if "%GRUB_DUN%"=="" usb --init && set GRUB_DUN=1 && pause --wait=3
# Switch to grub4dos 0.4.5c ALWAYS if 045 set
if "%GRUB_USB%"=="045" if exist /%grub%/grldr_045 && cat --locate="4DOS 0.4.6" (md)0x200+0x80 > nul && chainloader /%grub%/grldr_045 > nul && boot
# set debug message level for 0.4.6
errorcheck off
debug 0
if "%GV%"=="046" debug msg=1 > nul
errorcheck on
debug normal
set GV=


#load users keyboard map settings
#if not "%DONEMENU%"=="1" if exist /%grub%/KBD.g4b call /%grub%/KBD.g4b %redirp%
if not "%DONEMENU%"=="1" if exist KBD if exist /%grub%/%KBD% call /%grub%/%KBD% %redirp%
set KBD=

#GRAPHICSMODE - use 640x480 and default background if cannot set mode
if not "%DONEMENU%"=="1" if "%GFX%"=="" graphicsmode -1 %GMODE% > nul || if not "%DONEMENU%"=="1" if "%GFX%"=="" graphicsmode -1 640 > nul && if exist /%grub%/Background.bmp.gz set MYWBMPGZ=/%grub%/Background.bmp.gz
set GMODE=

echo %@time% menu.lst Start loading Fontfile >> (md)0x9999+3
# load fontfile to support chinese, etc. characters
set FF=
if "%NOUNIFONT%"=="" if exist ()/%grub%/unifont.hex.gz set FF=1
if exist FF echo Loading "unifont.hex.gz" for UTF-8 character support...  %redir%
# reset to use the BIOS FONTS and get ready to load new font
font
if exist FF font ()/%grub%/unifont.hex.gz

if not exist %FONT% echo  $[0174] WARNING: %FONT% Font file NOT FOUND! && set FONT=
if not "%FONT%"=="" font && font %FONT% && echo User font file "%FONT%" loaded. %redirp%
# if BIOSFONT is defined then reload BIOS ROM fonts for chars 0-ff (get thicker characters)
if not "%BIOSFONT%"=="" font && echo BIOS font loaded
set FONT=
set NOUNIFONT=
set BIOSFONT=
set FF=
echo %@time% menu.lst Finished loading Fontfile >> (md)0x9999+3

#if not "%DONEMENU%"=="1" clear
echo Booting Easy2Boot %VER% (2) and loading background image - please wait... %redir%
echo %@time% menu.lst Booting (2) - Loading background >> (md)0x9999+3
#WALLPAPER
if  exist /%grub%/Background.bmp.gz set BG=/%grub%/Background.bmp.gz
if  exist /%grub%/Background.bmp set BG=/%grub%/Background.bmp
if  exist %MYWBMP% set BG=%MYWBMP%
if  exist %MYWBMPGZ% set BG=%MYWBMPGZ%
echo Using %BG% as Wallpaper %redirp%
if "%GFX%"=="" if not "%DONEMENU%"=="1" if not "%BG%"=="" splashimage %BG% > nul && clear
set MYWBMP= && set MYWBMPGZ= && set BG=
echo %@time% menu.lst Loading hotkey app >> (md)0x9999+3

#load hotkey support (not supported by gfxmenu)
if "%GFX%"=="" /%grub%/hotkey > nul && echo Hotkey loaded %redir%
if /i "%GFX%"=="NONE" /%grub%/hotkey > nul && echo Hotkey loaded %redir%

echo Booting Easy2Boot %VER% (3) - please wait... %redir%
echo %@time% menu.lst Booting (3) menusetting >> (md)0x9999+3

#will restore max menu grub4dos default (screws up though!)
#/%grub%/menusetting.gz u

# set menu position (clears the screen so use clear afterwards to fill the screen with background colour)
if "%GFX%"=="" if not "%DONEMENU%"=="1" /%grub%/menusetting.gz   %wdspace% %lnspace% %bdwidth% %tophelp% %noitems% %topstart% %menuw% %rstart%

# must clear here as menusetting blanks screen and lose background
clear

echo Booting Easy2Boot %VER% (4) - counting files - please wait... %redirp%
echo %@time% menu.lst Booting (4) (check ptn 4) >> (md)0x9999+3

# calculate padding for headings
if not exist HPAD call /%grub%/SetHPAD.g4b %rstart%
# HPAD now has correct number of spaces for padding the headings

#clear variables
set wdspace= && set lnspace= && set topstart= && set rstart= && set noitems= && set menuw= && set bdwidth= && set tophelp=

#only run somethings once or will screw up the menu!
#set so we don't load bitmap or set graphics mode again (saves time) or run menusetting program
set DONEMENU=1

#autonumber all menu entries with a space (20) and a number
if "%AUTONUM%"=="" set AUTONUM=0x10002001
write 0x8274 %AUTONUM% > nul

debug 0
# check and make empty table entry in 4th position in ptn table
if not exist CD parttype (%E2BDEV%,3) ;; set /A check=%@retval%
if not exist CD if %check%==0 partnew (%E2BDEV%,3) 0 0 0
if not exist CD if %check%==0xaf echo -e $[0104]\nTip: You can use a MyE2B.cfg file to erase partition 4 and avoid this message in future.
if not exist CD if %check%==0xeb echo -e $[0104]\nTip: You can use a MyE2B.cfg file to erase partition 4 and avoid this message in future.
if not exist CD if not %check%==0 echo -e $[0104]ERROR: PARTITION TABLE 4 (Type=%check%) IS ALREADY IN USE ON THIS DRIVE! && set /p ask=Press C and [Enter] to delete it :  &; if /i "%ask%"=="C" /_ISO/e2b/grub/delptn3.g4b
if not exist CD if not %check%==0 if /i not "%ask%"=="C" configfile /menu.lst
set ask=

# check and make empty 3rd position (no warning as only some .mnu files need this)
if not exist CD parttype (%E2BDEV%,2) ;; set check=%@retval%
#if 3rd ptn type is 0 then ensure all CHS values are 0 or grubinst.exe will not install!
if not exist CD if %check%==0 partnew (%E2BDEV%,2) 0 0 0
set check=

# turn off page mode so it doesn't pause when console screen is full!
pager off

# DO NOT CHANGE!
set MFOLDER=/_ISO/MAINMENU
#if LBACKMENU is blank there will be no Back F8 menu entry
set LBACKMENU=

set STALE=
cat --locate=YES ()/FASTLOAD.YES > nul && set STALE=1

# set count of Windows ISO files to 0 before counting
set CALL=0
#count Windows ISOs in \_ISO\WINDOWS folders - but not if FASTLOAD is enabled
echo %@time% menu.lst Starting counting Windows ISO Files >> (md)0x9999+3
if not exist STALE call /%grub%/countfiles.g4b
echo %@time% menu.lst Finished counting Windows ISO Files >> (md)0x9999+3

#always count if WINCOUNT is set in MyE2B.cfg (allows $$$$.mnu file for new splashimage to be added)
if exist WINCOUNT if exist STALE call /%grub%/countfiles.g4b

# clear out FASTLOAD.MNU
if not exist CD && if exist /FASTLOAD.NO echo REFRESH               > /FASTLOAD.NO
# Load the FASTLOAD MENU if enabled by user
# if cache is valid and we are cached (YES) then set FST=1
set FST= && cat --locate=title --number=1 ()/%grub%/FASTLOAD.MNU > nul && cat --locate=YES ()/FASTLOAD.YES > nul && set FST=1
# if FASTLOAD.MNU cache is invalid then must refresh it (can happen if user updates with new version)
if not exist CD && if exist /FASTLOAD.YES cat --locate=title --number=1 ()/%grub%/FASTLOAD.MNU > nul ||  echo REFRESH > /FASTLOAD.YES 
 
if "%FST%"=="1" echo -e \n$[0106]Loading PRE-CACHED FASTLOAD MENU...\n %redir% 
if "%FST%"=="1" if "%redir%"=="" pause --wait=2 > nul 
if "%FST%"=="1" cat ()/%grub%/FASTLOAD.MNU > (md)0xA000+0x50
#beep the speaker to say we are ready! use 1-3 beeps
if "%FST%"=="1" if exist beep if %beep%>=1 /%grub%/bios int=0x10 eax=0xe07 ebx=0x0 > null
if "%FST%"=="1" if exist beep if %beep%>=2 /%grub%/bios int=0x10 eax=0xe07 ebx=0x0 > null
if "%FST%"=="1" if exist beep if %beep%>=3 /%grub%/bios int=0x10 eax=0xe07 ebx=0x0 > null
if "%FST%"=="1" set beep=
if "%FST%"=="1" call Fn.70 2 
if "%FST%"=="1" set FST= && set MFOLDER=/_ISO/MAINMENU && configfile (md)0xA000+0x50

#  --- START BUILDING MAIN MENU IN MEMORY ---

# copy menu to start of menu.lst in ramdrive

echo ###### MAIN MENU ####### > (md)0x3000+0x50

# translate MAIN.hdr and copy to (md)0x3000
call /%grub%/XLATE.g4b ()/%grub%/MAIN.hdr

if not "%pwd%"=="" echo -e \npassword %pwd% >> (md)0x3000+0x50
echo debug 0 >> (md)0x3000+0x50
echo set MFOLDER=/_ISO/MAINMENU >> (md)0x3000+0x50

# SET MENU DEFAULT AND TIMEOUT
if exist /%grub%/menu_defaults.txt cat /%grub%/menu_defaults.txt >> (md)0x3000+0x50
if exist /_ISO/menu_defaults.txt && cat /_ISO/menu_defaults.txt >> (md)0x3000+0x50 && echo $[0104]Using \_ISO\menu_defaults.txt for Main Menu default settings %redirp%

# add Windows counts to menu for FASTLOAD
if not exist WINCOUNT if exist /FASTLOAD.YES echo -e iftitle [set CALL=%CALL% \&\& set CXP=%CXP% \&\& set CV=%CV% \&\& set C7=%C7% \&\& set C8=%C8% \&\& set C28=%C28% \&\& set C12=%C12% \&\& set C10=%C10% \&\& if 1=0] dummy\nboot\n >> (md)0x3000+0x50

# if GFX was set to suppress graphics mode then clear it as we are not using GFXMENU system really
if /i "%GFX%"=="NONE" set GFX=

#write 'set defaults' menu to menu (not supported by gfxmenu!)
#if not exist CD if "%GFX%%DEFMENU%"=="" call /%grub%/XLATE.g4b ()/%grub%/MenuDefaults.hdr
if  exist CD set DEFMENU=0
if not "%GFX%"=="" set DEFMENU=0


# fresh screen to get most items on without scrolling screen
clear

# generate the menu.lst file and specify the  Main Folder that will be scanned for .mnu files
#suppress new configfile by setting to NONE - so will add to existing menu in ramdrive
set STARTMENU=NONE
::set LBACKMENU=1
echo Adding menu entries from files in /_ISO/MAINMENU... %redirp%
echo %@time% menu.lst Enumerating all files in \_ISO\MAINMENU >> (md)0x9999+3
/%grub%/AUTOMN.g4b .automenu /_ISO/MAINMENU
echo %@time% menu.lst Starting XML and Helper drive search >> (md)0x9999+3
set STARTMENU=

#FASTLOAD
# Write menu for fast load next time
if not exist CD cat --locate=REFRESH /FASTLOAD.YES > nul && cat (md)0x3000+0x50 > /%grub%/FASTLOAD.MNU && echo YES > /FASTLOAD.YES && if not exist redir echo $[0106]NOTE: The Fastload Menu has been refreshed. && pause --wait=2 > nul && echo 
set FL=

# invalidate .xml files in the root of both drives - don't stop on errors
echo Wiping /AutoUnattend.xml and /Unattend.xml files... %redirp%
debug 1
# don't abort if error
errorcheck off

# 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 sometimes hangs if bad bios!
if not exist CD if exist ()/AutoUnattend.xml dd if=(rd)+1 of=()/AutoUnattend.xml > nul
if not exist CD if exist ()/AutoUnattend.xml dd if=()/_ISO/e2b/firadisk/empty.xml of=()/AutoUnattend.xml > nul
if not exist CD if exist ()/Unattend.xml     dd if=(rd)+1 of=()/Unattend.xml > nul
if not exist CD if exist ()/Unattend.xml     dd if=()/_ISO/e2b/firadisk/empty.xml of=()/Unattend.xml > nul
if not exist NOHELPER echo -n Looking for /WINHELPER.USB %redirp%
if not exist NOHELPER set AUX=
if not exist NOHELPER if exist (hd1,0)/WINHELPER.USB root (hd1,0) > nul && set AUX=1
if not exist NOHELPER if "%AUX%"=="" echo -n . %redirp%
if not exist NOHELPER if "%AUX%"=="" if exist (hd0,0)/WINHELPER.USB root (hd0,0) > nul && set AUX=1
if not exist NOHELPER if "%AUX%"=="" echo -n . %redirp%
if not exist NOHELPER if "%AUX%"=="" if exist (hd2,0)/WINHELPER.USB root (hd2,0) > nul && set AUX=1
if not exist NOHELPER if "%AUX%"=="" echo -n . %redirp%
if not exist NOHELPER if "%AUX%"=="" if exist (hd3,0)/WINHELPER.USB root (hd3,0) > nul && set AUX=1
if not exist NOHELPER if "%AUX%"=="" echo -n . %redirp%
if not exist NOHELPER if "%AUX%"=="" if exist (hd4,0)/WINHELPER.USB root (hd4,0) > nul && set AUX=1
if not exist NOHELPER if "%AUX%"=="" echo -n . %redirp%
if not exist NOHELPER if "%AUX%"=="" if exist (hd5,0)/WINHELPER.USB root (hd5,0) > nul && set AUX=1
if not exist NOHELPER if "%AUX%"=="" echo -n . %redirp%
if not exist NOHELPER if "%AUX%"=="" if exist (hd6,0)/WINHELPER.USB root (hd6,0) > nul && set AUX=1
if not exist NOHELPER if "%AUX%"=="" echo -n . %redirp%
if not exist NOHELPER if "%AUX%"=="" if exist (hd7,0)/WINHELPER.USB root (hd7,0) > nul && set AUX=1
if not exist NOHELPER if "%AUX%"=="" echo -n . %redirp%
if not exist NOHELPER if "%AUX%"=="" if exist (hd8,0)/WINHELPER.USB root (hd8,0) > nul && set AUX=1
if not exist NOHELPER if "%AUX%"=="" echo -n . %redirp%
if not exist NOHELPER if "%AUX%"=="" if exist (hd9,0)/WINHELPER.USB root (hd9,0) > nul && set AUX=1
if not exist NOHELPER if "%AUX%"=="" echo -n . %redirp%
if not exist NOHELPER echo %redirp%
if not exist NOHELPER if "%AUX%"=="1" echo -n Wiping /AutoUnattend.xml and /Unattend.xml files on WINHELPER.USB... %redirp%
if not exist NOHELPER if "%AUX%"=="1" if exist ()/AutoUnattend.xml dd if=(rd)+1 of=()/AutoUnattend.xml > nul && echo -n A %redirp%
if not exist NOHELPER if "%AUX%"=="1" if exist ()/AutoUnattend.xml dd if=(bd)/_ISO/e2b/firadisk/empty.xml of=()/AutoUnattend.xml > nul && echo -n a %redirp%
if not exist NOHELPER if "%AUX%"=="1" if exist ()/Unattend.xml     dd if=(rd)+1 of=()/Unattend.xml > nul && echo -n U %redirp%
if not exist NOHELPER if "%AUX%"=="1" if exist ()/Unattend.xml     dd if=(bd)/_ISO/e2b/firadisk/empty.xml of=()/Unattend.xml > nul && echo -n u %redirp%
set AUX=
root (bd) > nul
errorcheck on
debug 1
echo %redirp%

echo %@time% menu.lst Finished XML and Helper drive search >> (md)0x9999+3

#cache the Main Menu in memory at 0xA000 (20MB)
dd if=(md)0x3000+0x50 of=(md)0xA000+0x50 > nul

#beep the speaker to say we are ready! use 1-3 beeps
if exist beep if %beep%>=1 /%grub%/bios int=0x10 eax=0xe07 ebx=0x0 > null
if exist beep if %beep%>=2 /%grub%/bios int=0x10 eax=0xe07 ebx=0x0 > null
if exist beep if %beep%>=3 /%grub%/bios int=0x10 eax=0xe07 ebx=0x0 > null
set beep=

# Load the new configfile
echo Loading the Main menu... %redirp%
echo -e %@time% menu.lst END >> (md)0x9999+3

if exist SHOWTIME echo -e \n\nSHOWTIME\n======== && cat (md)0x9999+3 && echo && pause Press a key to load the Main Menu...

# normal cursor
call Fn.70 2

# set default extension for executables
command --set-ext=.g4b > nul
# set default path for executables
command --set-path=/%grub% > nul


configfile (md)0xA000+0x50


