57 - Automatic grub4dos menus, using hotkeys, hiding the menu and silent startup

Unique hits statistics in vBulletin


If you have followed some of these tutorials, you may have several grub4dos USB drives with different 'payloads' (e.g. ISO files, IMG files, IMA files, etc.) on them. You may find that you often change the contents of your USB drive and when you do, you have to remember to delete some of the menu entries whenever you remove a large file such as an ISO file. If you later add back the ISO file, you will also then need to add back in the correct menu entry. Alternatively, you have to comment out any menu entry that is no longer valid and then uncomment it later if you add back the relevant ISO file.

However, there is a way to automatically show only valid menu entries in a grub4dos menu. We can make grub4dos look for the 'payload' file and only list the menu entry if the payload file exists. Once you have set up your grub4dos menu, you can simply add or delete any ISO/IMG/IMA/WIM file from the USB drive and the menu entry for that file will automatically appear or disappear the next time you boot from the USB drive. Any grub4dos bootable USB drive you make in future can simply have your full menu copied to it, but it will only list menu entries for the files that exist on the USB drive.

The way to do this is to use the iftitle command  (2012 grub4dos versions or later, or use latest version of RMPrepUSB to install grub4dos) which can be used to check for the existence of the payload file, for example:

iftitle [if exist (bd)/test.img] find /test.img on any drive and boot to it
map --mem (bd)/test.img (fd0)
map --hook
chainloader (fd0)+1

Note that no spaces must be present after the [ or before the ] brackets or it may not work correctly. The statement inside the [ ] brackets must equate to TRUE for the menu entry to be listed by grub4dos.

iftitle with menu auto-numbering

The latest chenall build of grub4dos (in latest RMPrepUSB) has the new command iftitle. Now you can make your menu.lst easily without needing any extra lines of code. Use RMPrepUSB and the Install grub4dos button. Here are some examples for the new iftitle command and also a patch to make the grub4dos menu automatically number itself:

#autonumber boot entries with a space (20) after the number
write 0x8274 0x2001

#autonumber boot entries with a hyphen (2d) after the number
#write 0x8274 0x2d01

#autonumber all entries (ff) including non-boot entries with a space (20) after the number
#write 0x8274 0x20ff

iftitle [if exist (hd0,0)/test.img] boot to (hd0,0)/test.img
map --mem (hd0,0)/test.img (fd0)
map --hook
chainloader (fd0)+1

iftitle [find /test.img] find /test.img on any drive and boot to it
find --set-root /test.img
map --mem /test.img (fd0)
map --hook
chainloader (fd0)+1

iftitle [if exist /win764.iso && checkrange 2,3 is64bit] for 64-bit system
(load a 64-bit only ISO)

iftitle [if exist /win732.iso && checkrange 0,1 is64bit] for 32-bit system
(load a 32-bit only OS)

iftitle [checkrange 0x80 read 0x8280] We have booted from a hard disk type device
(load from hd here)

iftitle [ls /boot] check if the folder /boot exists
(do stuff here)

iftitle [find --set-root --devices=h /bootmgr && call set bootmgr=%@root^%] load BOOTMGR of Windows VISTA/WIN7/WIN2008 on %bootmgr%
# we must set the current root again, as it may be changed by any following iftitle commands as each iftitle menu command is loaded and run...
find --set-root --devices=h /bootmgr
echo Booting from %bootmgr%/bootmgr ...
chainloader /bootmgr

Beware: the syntax if very fussy - you must not have any white space immediately after the [ or before the ] brackets!


If a command returns <false> you can check the results using checkrange
iftitle [checkrange 0x01:0xff hiddenflag (hd0,0)] ptn 0 is hidden
root ()

iftitle [checkrange 0x0 hiddenflag (hd0,0)] ptn 0 is unhidden
root ()

iftitle [checkrange 0x01:0xff hiddenflag (hd0,1)] ptn 1 is hidden
root ()

iftitle [checkrange 0x0 hiddenflag (hd0,1)] ptn 1 is unhidden
root ()


The auto-number patch (write 0x8274 aabb line), can be used to auto-number all menu entries, however, all title commands will be numbered, even blank ones - e.g.

#autonumber all entries (including non-bootable entries) and add a hyphen (2d) after the number
write 0x8274 0x2dff

title This is menu title
root

title
root

title This is next menu title
root


will appear when you boot to grub4dos as 

 0-This is menu title

 2-This is next menu title

Add hotkey menu entries

The latest chenall build of grub4dos can be used with a new 'hotkey' executable to enable the user to use hotkeys such as F1 or CTRL+F1 to pick a menu entry. Then download the file 'hotkey.zip' from the grubutils download page here and extract the file hotkey and place it on the USB drive also. Now you can add hotkeys to your menu as follows:

          ## run the hotkey command
/hotkey
## run hotkey once to enable hotkeys.
## this will also auto enable hotkeys in any sub-menu 
## "hotkey"      = when user presses hotkey execute that menu entry immediately
## "hotkey -u"  = uninstall (disable) hotkey (can be used in sub-menus)
## "hotkey -nc" = only "hotkeys" and "arrow keys" accepted, other keys such as number keys or 'c' or 'e' etc. will be ignored. Executes menu immediately hotkey is pressed
## "hotkey -nb" =  only selects the correct menu entry when a hotkey is pressed - it does not auto boot it, the user must press the Enter key.
## "hotkey -nc -nb" = select menu entry when hotkey pressed, number keys and other keys ignored, must use hotkey or cursor keys to select a menu

title ^F1 Press F1 to Boot From (hd0,0)
chainloader (hd0,0)+1

title ^Ctrl+F1 Press Ctrl+F1 to boot From (hd0,0)/ntldr
chainloader (hd0,0)/ntldr

iftitle [find --set-root --devices=h /bootmgr] ^F2 Press F2 to Boot Windows from hard disk 
find --set-root --devices=h /bootmgr
chainloader /bootmgr

title ^R Reboot
reboot

title [H] Halt
halt


The menu presented to the user will look like this (if bootmgr is present on a hard disk device):

Press F1 to Boot From (hd0,0)
Press Ctrl+F1 to boot From (hd0,0)/ntldr
Press F2 to Boot Windows from hard disk
Reboot
[H] Halt 

Note that the ^F1 portion of the menu text is not displayed if 'hotkey' has been loaded (but it will be displayed if hotkey has not been loaded and hotkeys will not work).
^ means do not show the hotkey
[xx] means display the hotkey
If the user presses F1 the first menu entry will immediately run. If you use hotkey -nc then pressing F1 will only select the first menu entry but will not run it until the user hits {Enter}.

You can use Ctrl+, Shift+ and Alt+ as modifiers.

Avoid using number keys (e.g ^1) as the user usually presses a number to select a menu entry. You can use Shift+1 or Alt+1 or Ctrl+1 instead.

Avoid using ^P, ^E and  ^C as these are normal grub4dos menu edit keys. Also 'B' can be used instead of the [Enter] key to boot a selected menu item, so also avoid using ^B as a hotkey.

Note: GFXMenu does not support hotkeys and so will display the complete title entry - e.g. ^R Reboot

Autoboot

If you want to automatically boot from a USB drive depending on what boot file you have on your USB key, you can do it like this (you must have the file default in the root of the drive - this special file can be downloaded from the Beta Downloads page)

default /default
timeout 20

if exist /test.img default 0 && timeout 1
if exist /win764.iso && checkrange 2,3 is64bit && default 1 && timeout 1
if exist /win732.iso && checkrange 0,1 is64bit && default 2 && timeout 1

title find /test.img on any drive and boot to it
find --set-root /test.img
map --mem /test.img (fd0)
map --hook
chainloader (fd0)+1

title 64-bit system
(load a 64-bit only ISO)

title 32-bit system
(load a 32-bit only OS)


Suppress grub4dos startup/bootup messages (silent)

grub4dos (grldr) echoes some debug messages to the screen on startup as it boots, which you may not want the user to see. They can be patched out by using a grub4dos batch file. 
Run this  patchg4d.g4b batch file at the start of your menu.lst - it will automatically make the code patches to blank out the messages the first time it is run.
It only needs to be run once (on a real system, not QEMU) for the patch to take affect.
e.g.

# patch out messages for silent startup
/patchg4d.g4b

Contents of the patchg4d.g4b file

!BAT
#patch to get rid of grub4dos startup text!
#first check if already done and exit if it has!

cat --locate="Running menu" --number=1  ()/grldr  > nul || goto :EOF

#Max locate string length=16 bytes
#Do not exceed original string length
#End of string is a 0 byte (\0)

cat --locate="Try (hd0,0 )" --number=1 --replace=\0\0 (hd0)+20 > nul
cat --locate="EXT2: " --number=1 --replace=\0\0 (hd0)+20 > nul
cat --locate="NTFS5: " --number=1 --replace=\0\0 (hd0)+20 > nul
cat --locate="FAT32: " --number=1 --replace=\0\0 (hd0)+20 > nul
cat --locate="FAT16: " --number=1 --replace=\0\0 (hd0)+20 > nul
cat --locate="FAT12: " --number=1 --replace=\0\0 (hd0)+20 > nul
cat --locate="non-MS: " --number=1 --replace=\0\0 (hd0)+20 > nul
cat --locate="skip " --number=1 --replace=\0\0 (hd0)+20 > nul
cat --locate="Extended: " --number=1 --replace=\0\0 (hd0)+20 > nul
cat --locate="invalid or null" --number=1 --replace=\0\0 (hd0)+20 > nul

cat --locate="Initialize var" --number=1 --replace=\0\0 ()/grldr > nul
cat --locate="Starting cmain" --number=1 --replace=\0\0 ()/grldr > nul
cat --locate="Running menu" --number=1 --replace=\0\0 ()/grldr > nul

#Default Help text:
#patch default: Use the %c and %c keys to highlight an entry.
#replace with:  Use the four cursor keys to select an entry.\0
#other strings:  
#              Press ENTER or 'b' to boot. Press 'e' to edit the commands before booting, or 'c' for a command line.
#              Press 'p' to gain privileged control etc....
              
#change message to use four cursor keys as < and > are valid keys
cat --locate="Use the %c and %" --number=1 --replace="Use the four cursor keys to select an entry.\0" ()/grldr  > nul

#Don't tell user how to edit the menu!
cat --locate="Press \'e\' to edi" --number=1 --replace="\0" ()/grldr  > nul

echo Patching finished - press a key to reboot...
pause

reboot

Splash Screen Only (no menu on boot)

The user will just see the wallpaper image with no text or highlight line at all - if he presses F4 or F5 then the menu entry chosen will be executed immediately. Cut and paste the lines so that you get the correct number of spaces!

clear
debug off
graphicsmode -1 800  100:1000 24:32 > nul
splashimage /aurora24.bmp.gz > nul
# load hotkey utility
/hotkey
timeout 10
default 0

#set black text on black background so we see no menu or help text!
color black/black

# display the grub4dos heading and cover up grub4dos version text
write (md)0x220+1 !BAT\necho -n -P:0000 $[0133]                                                                                                   \0
initscript (md)0x220+1

# set 0 size border
/menusetting.gz   0 0 0 0 0 0 0 0

title ^F5 Reboot (F5) \nThis will reboot your PC
reboot

title ^F4 Halt (F4)\nThis will halt your PC
color standard=0x04
echo This text will be in red! Hit a key to HALT!
pause
halt

Only boot grub4dos if hotkey pressed

You can install grub4dos using grubinst.exe so that grldr and the grub4dos menu will only be loaded if a hotkey is pressed by the used. 
A (modified) copy of grubinst.exe is used by RMPrepUSB and can be found in the RMPrepUSB installation folder (press F3 to view the installation folder in Explorer).

Here is what the user will see when grub4dos is installed in this way:

1. Reboot or Switch on the computer
2. Normal PC startup screen appears
3. grub4dos stage 1 bootloader will run and this message will be displayed on the screen:

Press F10 to start GRUB, any other key to boot to previous MBR ...
Timeout: 3

4. The timeout will count down to 0 seconds (unless F10 is pressed) and then will boot from the boot disk as normal (using the bootloader that was on the drive before grub4dos was installed).
    If F10 is pressed, then the grldr stage 2 file is loaded which will look for your menu.lst file and load it and display the grub4dos menu.

The command line to install grub4dos in this way to your drive (assuming your drive is hd2 and you want a 3 second timeout)  is:

grubinst.exe  --boot-prevmbr-first --time-out=3 --hot-key=0x4400 --key-name=F10  (hd2)

Some Scan codes you can use are:
F12=8600, F11=8500, F10=4400, F9=4300, F8=4200, F7=4100, F6=4000, F5=3F00, F4=3E00, F3=3D00, F2=3C00, F1=3B00, ESC=011B  (use pause --test-key to print any key scan code)

Note: It is best to avoid using F12 or F11 as these often do not work on some models of Notebooks due to non-standard notebook keyboards.

All the command line switches for grubinst.exe can be found here.


To change the message, boot from the disk to grub4dos and use the following grub4dos patch command from the grub4dos command shell.

cat --locate=" to start GRUB," --number=1 --replace=" to Restore the Hard Disk Image.\0" (hd0)+20 > nul

Note that the --replace string must not be longer than 53 characters or you will corrupt the boot code!

If you want to entirely suppress the 'Press F10 to start...' message and the Timeout message and just have the 3..2..1..0 countdown displayed, the following grub4dos commands will patch the disk that grub4dos is installed on, to suppress these messages (omit !BAT if you are typing this into the console):

!BAT
cat --locate="Press " --number=2 --replace=\0\0 (hd0)+20 > nul
cat --locate=" to start GRUB," --number=1 --replace=\0\0 (hd0)+20 > nul
cat --locate="Timeout : " --number=1 --replace=\0\0 (hd0)+20 > nul
cat --locate="F10" --number=1 --replace=\0\0 (hd0)+20 > nul
cat --locate="hot-key" --number=1 --replace=\0\0 (hd0)+20 > nul

You can make this into a text batch file - e.g. nomsg.g4b, by keeping the first line of text "!BAT" , and then run the batch file from the command line by typing /nomsg.g4b.

Disguise (obfuscate) the menu.lst file

To obscure the text in the menu.lst file so that it cannot be easily read as plain text by a curious end user, compress it using 7Zip to the Gzip format (but keep the filename as menu.lst).














        NOTE: THE CONTENT BELOW IS OUTDATED!                          


The Methods below are deprecated. The new grub4dos iftitle command makes these workarounds no longer necessary! They are included for the interested reader only!


NOTE: PLEASE USE THE LATEST CHENALL BUILD GRUB4DOS VERSION (also included with the latest RMPrepUSB download)

Note: Method 2 uses two menu files (menu.lst and main.lst) and allows you to expand the scheme so that you could modify more than one menu file (e.g. you can have main.lst which would load either main1.lst, main2.lst, main3.lst, etc.). This is useful if your menu system uses multiple menu files. If you only use one menu.lst file (probably 90% of users!) then you can use just a single self-modifying file (i.e. one menu.lst) as in Method 1.


(OLD) Method 1 - Method using a single MENU.LST file

1. Cut and paste the lines in the template example below (up to the # YOUR NORMAL GRUB4DOS MENU GOES HERE position) into your existing menu.lst file (insert at the very top of your menu.lst). The --replace="   " text should have EXACTLY 3 SPACES between the double-quotes.

2. Modify your existing menu entries by adding four-character identifiers (#XX<space>) to the beginning of each of your menu lines as detailed above and as shown in the example menu below.

3. Modify the 'if exist' lines (just below the #PLACE ALL YOUR TEST ENTRIES HERE text) so that they match the identifiers you used in step 2 and match the iso or 'payload' file used by each menu entry.


Alternatively, just use the utility to convert your existing menu.lst
Download the GrubAuto utility to convert your current menu.lst to an 'automated' one!

1. Click on the Load Menu button and select your current menu.lst file
2. Click on Copy To ClipBoard
3. Paste the contents into a new menu.lst file and save it.




Menu.lst template (green text is the original menu text):

cat /menu.lst > (md)800+100
cat --locate="cat /menu.lst" --replace="#" (md)800+100 >nul
cat --locate="configfile (md)"  --replace="#" (md)800+100 >nul

#PLACE ALL YOUR TEST ENTRIES HERE
if exist /trk3/menu.lst         cat --locate=#TR --replace="   " (md)800+100 >nul
if exist /dban-2.2.6_i586.iso   cat --locate=#DK --replace="   " (md)800+100 >nul

#load menu from ram
echo Loading modified menu.lst...
configfile (md)800+100

# YOUR NORMAL GRUB4DOS MENU GOES HERE
# Place all your normal grub4dos menu entries here
# No special changes are needed except for adding the #XX characters at the beginning of each command line

color black/cyan yellow/cyan
timeout 5
default 1

#TR title Trinity Rescue v3.4
# You must set your own drive's volume label on the next line or it will not load correctly!
#TR set VOL=RMPREPUSB
#TR configfile /trk3/menu.lst

#DK title Dariks Boot and Nuke dban-2.2.6_i586.iso
#DK find --set-root --ignore-floppies /dban-2.2.6_i586.iso
#DK map --mem --heads=0 --sectors-per-track=0 /dban-2.2.6_i586.iso (0xff)
#DK map --hook
#DK root (0xff)
#DK chainloader (0xff)


How it works

This menu.lst is self-modifying. It loads itself into memory (1st line) and then comments out the lines that loaded it into memory in the next two lines (otherwise it would loop and continuously keep loading itself into memory!). The self-modification is done by looking for two command lines and then commenting those lines out.
The 'if exist' lines are not commented out, so they will actually run twice and the second time menu.lst is loaded from memory, it will change itself - but it does not matter (except it will take slightly longer to run) because the menu lines will have already been modified when the 'if exist' lines ran the first time!



(OLD) 

Method 2 (using two menu files)


1. First rename your menu.lst file to main.lst

2. Next add 4 characters to the beginning of each non-commented menu entry in the main.lst file. The first character you add should be a #, the next can be any 2 alphanumeric characters and the last one should be a space - thus making four characters in total added to each non-commented line. The 2nd and 3rd character should be different for each menu entry.

For example, suppose you have menu entries for KonBoot and MemTest86+ as shown below:

title KONBOOT\nPress Enter once Kon-Boot starts to run then allow it to reboot your system to Windows
errorcheck off 
map --mem /FD0-konboot-v1.1-2in1.img (fd0)
# If current grub4dos root drive (UDF)(stored at 0x8280 in memory) is 0x80 (=hd0), remap (hd0) to (hd1), else do nothing
checkrange 0x80 read 0x8280 && map (hd0) (hd1)
# If current grub4dos root drive (UDF) (stored at 0x8280 in memory) is 0x80 (=hd0), remap (hd1) (=internal hard drive) to (hd0), else do nothing
checkrange 0x80 read 0x8280 && map (hd1) (hd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)

title MEMTEST86+
find --set-root /mt410.iso
map /mt410.iso (hd32)
map --hook
root (hd32)
chainloader (hd32)

This could be changed to:

#KB title KONBOOT\nPress Enter once Kon-Boot starts to run then allow it to reboot your system to Windows
#KB errorcheck off 
#KB map --mem /FD0-konboot-v1.1-2in1.img (fd0)
# If current grub4dos root drive (UDF)(stored at 0x8280 in memory) is 0x80 (=hd0), remap (hd0) to (hd1), else do nothing
#KB checkrange 0x80 read 0x8280 && map (hd0) (hd1)
# If current grub4dos root drive (UDF) (stored at 0x8280 in memory) is 0x80 (=hd0), remap (hd1) (=internal hard drive) to (hd0), else do nothing
#KB checkrange 0x80 read 0x8280 && map (hd1) (hd0)
#KB map --hook
#KB chainloader (fd0)+1
#KB rootnoverify (fd0)

#MT title MEMTEST86+
#MT find --set-root /mt410.iso
#MT map /mt410.iso (hd32)
#MT map --hook
#MT root (hd32)
#MT chainloader (hd32)

Note that we have now commented out all the menu lines!
The lines that were already commented out with a single # do not need to be changed.

3. To the top of the main.lst file add these two lines:

map --unhook
map --unmap=hd60

This undoes the mapping that we will need to do in menu.lst (see below).

4. Now make a new file called menu.lst and add the contents as shown below

# prevent abort if error
errorcheck off
map --mem /main.lst (hd60)
map --hook
# enable menu entries if payload file exists - ensure there are THREE SPACES between the replace doublequotes
if exist /FD0-konboot-v1.1-2in1.img cat --locate=#KB --replace="   " (hd60)+50 > nul
if exist /mt410.iso                         cat --locate=#MT --replace="   " (hd60)+50 > nul
# put more entries here
clear
echo Loading Main.lst
#load menu from ram
configfile (hd60)+50

Notice that you will need to add a line that tests for the presence of each 'payload' file (shown highlighted in grey for this example). Make sure that there are THREE SPACES between the double quotes in each line of the text --replace="   "

5. Now test the USB drive (you can use RMPrepUSB and press F11 to run QEMU). If some menu entries appear to be missing, check that the menu.lst file is checking the correct location for the 'payload' file including any path (not case sensitive).  e.g. if exist /iso/mt410.iso  or if exist /images/linux/gl40.iso .


That's it! Now you can add or delete any payload (ISO/IMG/IMA etc) file from your USB drive or make a new grub4dos bootable USB drive and just add the payload files that you want. You can always use the same menu.lst and main.lst files. If you ever need to add another menu, simply update both menu.lst and main.lst. You will never need to delete any menu entries ever again and you can build up your main.lst menu with working entries over the next few years without needing to edit it whenever you make a new USB drive.

If your main.lst menu file grows to more than 25K in size, change the (hd60)+50  number to a larger number (e.g. (hd60)+100 for a 50K file).

How it works

What we are doing is copying the main.lst menu file to memory (RAM) and then using the cat command to uncomment only the menu entries that we want to appear in our menu. This is done by replacing the three comment characters (e.g. #GP) with three spaces (if you want to use longer comment labels - e.g. #KONBOOT then you need to replace the 8 characters with the same number of spaces). Then we load the new altered menu file directly from memory using the configfile command. Because we are changing the menu text in RAM, it means that we don't need writeable media and so could use the same menu on a CD or DVD or write-protected media. The main.lst file is mapped to an arbitrary ram drive (hd60) and then changed and loaded by grub4dos - the ram drive is unmapped and discarded as soon as the main.lst menu runs.



A real life example using menu.lst and main.lst - the first menu entries in main.lst are assumed to be always present.
If you don't like the hex locations being listed on the screen briefly by the cat command, add  > nul to the end of each cat line.


menu.lst

# prevent abort if error
errorcheck off
map --mem /main.lst (hd60)
map --hook
# enable menu entries if payload file exists - ensure there are THREE SPACES between the replace doublequotes
if exist /_iso/DOS/dospak3.img                  cat --locate=#GP --replace="   " (hd60)+50 > nul
if exist /pmagic-5.8.iso                        cat --locate=#PM --replace="   " (hd60)+50
if exist /_ISO/linux/pclos.iso                  cat --locate=#PL --replace="   " (hd60)+50
if exist /_ISO/linux/RCDx86_298.iso             cat --locate=#PD --replace="   " (hd60)+50
if exist /_ISO/linux/pmagicapr.iso              cat --locate=#P4 --replace="   " (hd60)+50
if exist /_ISO/linux/pmagic52.iso               cat --locate=#P5 --replace="   " (hd60)+50
if exist /_ISO/linux/slitaz-3.0.iso             cat --locate=#SL --replace="   " (hd60)+50
if exist /_ISO/linux/slitaz-cooking.iso         cat --locate=#SC --replace="   " (hd60)+50
if exist /_ISO/linux/pmagic-5.7.iso             cat --locate=#CM --replace="   " (hd60)+50
if exist /_ISO/Windows/pebuilder.iso.gz         cat --locate=#BA --replace="   " (hd60)+50
if exist /_ISO/Windows/UBCD4WinBuilder.iso.gz   cat --locate=#UW --replace="   " (hd60)+50
if exist /_ISO/Windows/Hirens13.iso             cat --locate=#H3 --replace="   " (hd60)+50
if exist /_ISO/Windows/Hirens14.iso             cat --locate=#HI --replace="   " (hd60)+50
if exist /_ISO/linux/YLMF.iso                   cat --locate=#YL --replace="   " (hd60)+50
if exist /_ISO/linux/ubcd50.iso                 cat --locate=#UB --replace="   " (hd60)+50
if exist /_ISO/linux/pmagic-5.8.iso             cat --locate=#P8 --replace="   " (hd60)+50
if exist /_ISO/linux/pmagic-6.6.iso             cat --locate=#P6 --replace="   " (hd60)+50
if exist /_iso/linux/g4l-v0.38alpha48.iso       cat --locate=#G4 --replace="   " (hd60)+50
if exist /bt4/boot/initrd.gz                    cat --locate=#B4 --replace="   " (hd60)+50
if exist /BT5/casper/vmlinuz                    cat --locate=#BT --replace="   " (hd60)+50
if exist /mt410.iso                             cat --locate=#MT --replace="   " (hd60)+50
if exist /Bartpe.iso                            cat --locate=#BP --replace="   " (hd60)+50
if exist /minint/SETUPLDR.BIN                   cat --locate=#B1 --replace="   " (hd60)+50
if exist /ophcrack_vista/boot/bzImage           cat --locate=#OV --replace="   " (hd60)+50
if exist /ophcrack_xp/boot/bzImage              cat --locate=#OX --replace="   " (hd60)+50
if exist /cd100627.iso                          cat --locate=#PR --replace="   " (hd60)+50
if exist /acronis.iso                           cat --locate=#AC --replace="   " (hd60)+50
if exist /rescue/rescue.iso                     cat --locate=#KA --replace="   " (hd60)+50
if exist /live/vmlinuz1                         cat --locate=#CZ --replace="   " (hd60)+50
if exist /KNOPPIX511.iso                        cat --locate=#KP --replace="   " (hd60)+50
if exist /dsl4410.iso                           cat --locate=#DS --replace="   " (hd60)+50
if exist /dos622.ima.gz                         cat --locate=#MS --replace="   " (hd60)+50
if exist /memtest.img                           cat --locate=#MT --replace="   " (hd60)+50
if exist /FDD34.img                             cat --locate=#VI --replace="   " (hd60)+50
if exist /hdderase.img.gz                       cat --locate=#HE --replace="   " (hd60)+50
if exist /dban-2.2.6_i586.iso                   cat --locate=#DK --replace="   " (hd60)+50

# put more entries here
clear
echo Loading Main.lst
#load menu from ram
configfile (hd60)+50


main.lst

#gfxmenu /message
color black/cyan yellow/cyan
timeout 5
default /default
default 9
debug 1

map --unhook
map --unmap=hd60

title My Big Menu!
root

title 1 FreeDOS C: USB=HDD0
rootnoverify (hd0,0)
chainloader /kernel.sys

title 2 FreeDOS C: USB=HDD1\nType D:\COMFREE.COM after booting
map (hd0) (hd1)
map (hd1) (hd0)
map --hook
rootnoverify (hd1,0)
chainloader /kernel.sys

title 3 FreeDOS A: USB=FDD
map (hd0,0)+1 (fd0)
map (hd1) (hd0)
map --hook
chainloader (fd0)/kernel.sys
rootnoverify (fd0)
map --floppies=1
map --harddrives=1

title 4 MSDOS C: USB=HDD0
find --set-root /io.sys
chainloader /io.sys

title 5 MS-DOS C: USB=HDD1\nType D:\COMMAND.COM after booting
map (hd0) (hd1)
map (hd1) (hd0)
map --hook
rootnoverify (hd1,0)
chainloader (hd1,0)/io.sys

title 6 MS-DOS A: USB=FDD
map (hd0,0)+1 (fd0)
map (hd1) (hd0)
map --hook
rootnoverify (fd0)
chainloader (fd0)/io.sys
map --harddrives=1
map --floppies=1

title 7 Boot from HDD1
map (hd0) (hd1)
map (hd1) (hd0)
map --hook
chainloader (hd0,0)+1

title 8 Boot from HDD1 Partition 2
map (hd0) (hd1)
map (hd1) (hd0)
map --hook
chainloader (hd0,1)+1

title 9 WinPe SW DOWNLOAD (bcd)
map --mem /bootmgr (rd)
write --offset=0xE28 (rd)+1 \xEB\x08
### write unicode BCD
write --offset=0x54B68 (rd)+1 B\x00C\x00D\x00
chainloader (rd)+1
root ()

title 10 WinPe M DOWNLOAD (bc1)
map --mem /bootmgr (rd)
write --offset=0xE28 (rd)+1 \xEB\x08
### write unicode BC1
write --offset=0x54B68 (rd)+1 B\x00C\x001\x00
chainloader (rd)+1
root ()

title 11 WinPe v3 (bc2)
map --mem /bootmgr (rd)
write --offset=0xE28 (rd)+1 \xEB\x08
### write unicode BC2
write --offset=0x54B68 (rd)+1 B\x00C\x002\x00
chainloader (rd)+1
root ()

title 12 Reboot  \a
savedefault --wait=2
reboot

title 13 Switch Off
savedefault --wait=2
halt

#G4 title g4l - a disk/partition/file backup & restore utility
#G4 map /_iso/linux/g4l-v0.38alpha48.iso (0xff)
#G4 map --hook
#G4 chainloader (0xff)

#DK title Dariks Boot and Nuke dban-2.2.6_i586.iso
#DK find --set-root --ignore-floppies /dban-2.2.6_i586.iso
#DK map --mem --heads=0 --sectors-per-track=0 /dban-2.2.6_i586.iso (0xff)
#DK map --hook
#DK root (0xff)
#DK chainloader (0xff)

#HE title HDDErase floppy boot disk
#HE find --set-root /hdderase.img.gz
#HE map --mem --heads=0 --sectors-per-track=0 /hdderase.img.gz (fd0)
#HE map --hook
#HE root (fd0)
#HE chainloader (fd0)+1

#VI title VICTORIA BOOT FLOPPY (Russian) (Disk tool)
#VI find --set-root /FDD34.img
#VI map --mem --heads=0 --sectors-per-track=0 /FDD34.img (fd0)
#VI map --hook
#VI root (fd0)
#VI chainloader (fd0)+1

#P6 title pmagic-6.6.iso with PCCMOSCleaner and PCLoginNow Windows password reset
#P6 find --set-root --ignore-floppies /_ISO/linux/pmagic-6.6.iso
#P6 map --heads=0 --sectors-per-track=0 /_ISO/linux/pmagic-6.6.iso (0xff)
#P6 map --hook
#P6 root (0xff)
#P6 chainloader (0xff)

#P8 title Parted Magic 5.8 ISO (in ram hard disk)   WORKS
#P8 find --set-root /_ISO/linux/pmagic-5.8.iso
#P8 map --heads=0 --sectors-per-track=0 /_ISO/linux/pmagic-5.8.iso (hd32)
#P8 map --hook
#P8 root (hd32)
#P8 kernel /pmagic/bzImage noapic load_ramdisk=1 prompt_ramdisk=0 rw vga=791 sleep=10 loglevel=0 keymap=uk iso_filename=/_ISO/linux/pmagic-5.8.iso
#P8 initrd /pmagic/initramfs
#P8 map --unmap=0:0xff

#P8 title Parted Magic 5.8 - using Memdisk iso (hit TAB in syslinux menu and add vmalloc=256Mi ) 
#P8 kernel /memdisk iso
#P8 initrd /_ISO/linux/pmagic-5.8.iso

#MT title MEMTEST86+ using memdisk and memtest.img
#MT kernel /memdisk 
#MT initrd /memtest.img

#MS title MSDOS 6.22 using map --mem and chainloader with gz file
#MS find --set-root /dos622.ima.gz
#MS map --mem /dos622.ima.gz (fd0)
#MS map --hook
#MS rootnoverify (fd0)
#MS chainloader (fd0)+1

#UB title Ultimate Boot CD (UBCD) v5.0 final\nthis is the 14 May 2010 edition,its an all in one Free Bootable CD for IT Pros, the cd consolidate as many diagnostic tools as possible into one bootable CD.
#UB find --set-root /_ISO/linux/ubcd50.iso
#UB map /_ISO/linux/ubcd50.iso (hd32)
#UB map --hook
#UB root (hd32)
#UB chainloader (hd32)

#YL title YLMF (ubuntu XPmode)
#YL find --set-root /_ISO/linux/YLMF.iso
#YL map /_ISO/linux/YLMF.iso (0xff)
#YL map --hook
#YL root (0xff)
#YL kernel /casper/vmlinuz file=/cdrom/preseed/ylmf.seed boot=casper iso-scan/filename=/_ISO/linux/YLMF.iso
#YL initrd /casper/initrd.lz

#HI title Hirens Boot CD 14\nBoot to Hirens Boot CD in RAM 
#HI find --set-root --ignore-floppies --ignore-cd /_ISO/Windows/Hirens14.iso
#HI map  /_ISO/Windows/Hirens14.iso (0xff)
#HI map --hook
#HI root (0xff)
#HI chainloader (0xff)

#H3 title Hirens Boot CD 13.2 using  firadisk\nBoot to Hirens Boot CD in RAM 
#H3 find --set-root --ignore-floppies --ignore-cd /_ISO/Windows/Hirens13.iso
#H3 map --mem /_ISO/Windows/firadisk.gz (fd0)
#H3 map --mem  /_ISO/Windows/Hirens13.iso (0xff)
#H3 map --hook
#H3 root (0xff)
#H3 chainloader (0xff)

#UW title UBCD4WINBuilder with firadisk \nBoot to BartPE in RAM 
#UW find --set-root --ignore-floppies --ignore-cd /_ISO/Windows/UBCD4WinBuilder.iso.gz
#UW map --mem /_ISO/Windows/firadisk.gz (fd0)
#UW map --mem /_ISO/Windows/UBCD4WinBuilder.iso.gz (0xff)
#UW map --hook
#UW root (0xff)
#UW chainloader (0xff)

#BA title BartPE from ISO using firadisk
#BA find --set-root  --ignore-floppies --ignore-cd  /_ISO/Windows/pebuilder.iso
#BA map --mem /_ISO/Windows/pebuilder.iso.gz (0xff)
#BA map --mem /_ISO/Windows/firadisk.gz (fd0)
#BA map --hook
#BA root (0xff)
#BA chainloader (0xff)

#DS title DSLinux ISO NOT PRESENT!
#DS find --set-root /dsl4410.iso
#DS map /dsl4410.iso (hd32)
#DS map --hook
#DS root (hd32)
#DS chainloader (hd32)

#KP title KNOPPIX\nAt boot prompt type - knoppix bootfrom=/dev/hda0/KNOPPIX155.iso
#KP map /KNOPPIX511.iso (hd32) || map --mem /KNOPPIX511.iso (hd32)
#KP map --hook
#KP root (hd32)
#KP chainloader (hd32)

#CZ title CLONEZILLA (wait 2-3 minutes and hit Enter twice!)
;long wait at splash screen but it works!
#CZ kernel /live/vmlinuz1 locale=us boot=live persistent
#CZ initrd /live/initrd1.img

#CZ title CLONEZILLA hd0<->hd1 (wait 2-3 minutes and hit Enter twice!)
;long wait at splash screen but it works!
#CZ map (hd0) (hd1)
#CZ map (hd1) (hd0)
#CZ kernel /live/vmlinuz1 locale=us boot=live persistent
#CZ initrd /live/initrd1.img

#CM title PC CMOS Cleaner and Parted Magic 5.7 ISO
#CM find --set-root /_ISO/linux/pmagic-5.7.iso 
#CM map --heads=0 --sectors-per-track=0 /_ISO/linux/pmagic-5.7.iso (hd32)
#CM map --hook
#CM root (hd32)
#CM chainloader (hd32)

#KA title Kasperksy AV 2010 Rescue.iso
#KA map /rescue/rescue.iso (0xff) || --mem /rescue/rescue.iso (0xff)
#KA map --hook
#KA root (0xff)
#KA chainloader (0xff)

#AC title Acronis True Image 2009
#AC find --set-root /acronis.iso
#AC map /acronis.iso (hd32)
#AC map --hook
#AC root (hd32)
#AC chainloader (hd32)

#PR title Windows Password reset
#PR find --set-root /cd100627.iso
#PR map  /cd100627.iso (0xff)
#PR map --hook
#PR chainloader (0xff)

#OX title OphCrack Password Cracker XP 2.3.1
#OX find --set-root /ophcrack_xp/boot/bzImage 
#OX kernel /ophcrack_xp/boot/bzImage rw root=/dev/null vga=normal ophcrack=lowram lang=C kmap=uk screen=1024x768x16 autologin
#OX initrd /ophcrack_xp/boot/rootfs.gz 

#OV title OphCrack Password Cracker Vista 2.3.1
#OV find --set-root /ophcrack_vista/boot/bzImage 
#OV kernel /ophcrack_vista/boot/bzImage rw root=/dev/null vga=normal  ophcrack=lowram  lang=C kmap=uk screen=1024x768x16 autologin
#OV initrd /ophcrack_vista/boot/rootfs.gz 

#SC title SliTaz Cooking (may be no kbd in GUI?) NOT PRESENT
#SC find --set-root /_ISO/linux/slitaz-cooking.iso
#SC map --heads=0 --sectors-per-track=0 /_ISO/linux/slitaz-cooking.iso (0xff)
#SC map --hook
#SC root (0xff)
#SC kernel /boot/bzImage rw root=/dev/null 
#vga=normal lang=C kmap=uk screen=1024x768x16 autologin
#SC initrd /boot/rootfs.gz 

#SL title SliTaz 3.0
#SL find --set-root /_ISO/linux/slitaz-3.0.iso
#SL map --heads=0 --sectors-per-track=0 /_ISO/linux/slitaz-3.0.iso (0xff)
#SL map --hook
#SL root (0xff)
#SL kernel /boot/bzImage rw root=/dev/null 
#vga=normal lang=C kmap=uk screen=1024x768x16 autologin
#SL initrd /boot/rootfs.gz 

#P5 title Parted Magic 5.2 (direct mapping and booting the kernel)
#P5 find --set-root /_ISO/linux/pmagic52.iso
#P5 map --mem /_ISO/linux/pmagic52.iso (hd32)
#P5 map --hook
#P5 root (hd32)
#P5 kernel /pmagic/bzImage noapic load_ramdisk=1 prompt_ramdisk=0 rw vga=791 sleep=10 loglevel=0 keymap=us iso_filename=/_ISO/linux/pmagic52.iso
#P5 initrd /pmagic/initramfs
#P5 map --unmap=0:0xff

#P4 title Parted Magic 4.10 ISO (in ram hard disk)
#P4 find --set-root /_ISO/linux/pmagicapr.iso
#P4 map /_ISO/linux/pmagic.iso (hd32)
#P4 map --hook
#P4 root (hd32)
#P4 kernel /pmagic/bzImage noapic load_ramdisk=1 prompt_ramdisk=0 rw vga=791 sleep=10 loglevel=0 keymap=uk iso_filename=/_ISO/linux/pmagicapr.iso
#P4 initrd /pmagic/initramfs
#P4 map --unmap=0:0xff

#B1 title BartPE (from /MININT)
#B1 find --set-root /minint/SETUPLDR.BIN
#B1 chainloader /minint/SETUPLDR.BIN

#BP title BartPE ISO using  firadisk\nBoot to BartPE in RAM 
#BP find --set-root --ignore-floppies --ignore-cd /Bartpe.iso
#BP map --mem /firadisk.gz (fd0)
#BP map --mem /Bartpe.iso (0xff)
#BP map --hook
#BP root (0xff)
#BP chainloader (0xff)

#PD title PLD Linux RCDx86_298.iso
#PD find --set-root /_ISO/linux/RCDx86_298.iso
#PD map /_ISO/linux/RCDx86_298.iso (hd32)
#PD map --hook
#PD root (hd32)
#PD chainloader (hd32)

#PL title PCLinuxOS LiveCD \n * Booting from ISO image file
#PL map --unhook
#PL map --unmap=0:0xff
#PL find --set-root --ignore-floppies /_ISO/linux/pclos.iso
#PL map --heads=0 --sectors-per-track=0 /_ISO/linux/pclos.iso (0xff)
#PL map --hook
#PL root (0xff)
;kernel (0xff)/isolinux/vmlinuz fromusb bootfromiso=/_ISO/linux/pclos.iso livecd=livecd root=/dev/rd/3 acpi=on vga=788 keyb=en vmalloc=256M splash=silent debug
#PL kernel (0xff)/isolinux/vmlinuz fromusb bootfromiso=/_ISO/linux/pclos.iso livecd=livecd root=/dev/rd/3 acpi=on vga=788 keyb=en vmalloc=256M edd=off
#PL initrd (0xff)/isolinux/initrd.gz

#MT title MEMTEST86+ iso using memdisk iso and mt410.iso
#MT kernel /memdisk iso
#MT initrd /mt410.iso

#for UK with no splash screen and casper folder moved to \BT5\casper on USB drive
#noprompt suppresses the 'remove CD' message on reboot/shutdown - use splash intead of textonly if you prefer. The keyboard setting does not change the GUI keyboard setting.
#BT title BackTrack 5 (1024x768) Persistent\nType startx to run GUI once booted PERSISTENT
#BT kernel /BT5/casper/vmlinuz  file=/cdrom/preseed/custom.seed live-media-path=BT5/casper boot=casper locale=en_GB.UTF-8 keyb=uk   textonly noprompt vga=791-- persistent
#BT initrd /BT5/casper/initrd.gz

#MT title MEMTEST86+ using memdisk raw WORKS
#MT kernel /memdisk raw
#MT initrd /memtest.img

#B4 title BackTrack 4 Final LiveCD
#B4 find --set-root /bt4/boot/vmlinuz
#B4 kernel /bt4/boot/vmlinuz BOOT=/bt4/casper boot=/bt4/casper nopersistent rw quiet vga=0x315
#B4 initrd /bt4/boot/initrd.gz

#PM title Parted Magic 5.8 ISO with PC CMOS Cleaner (pmagic.iso)  NO WORK
#PM find --set-root /pmagic-5.8.iso 
#PM map --heads=0 --sectors-per-track=0 /pmagic-5.8.iso (hd32)
#PM map --hook
#PM root (hd32)
#PM chainloader (hd32)

#PM title Parted Magic 5.8 - using map --mem  NO WORK
#PM find --set-root /pmagic-5.8.iso
#PM map --heads=0 --sectors-per-track=0 --mem /pmagic-5.8.iso (hd32)
#PM map --hook
#PM root (hd32)
#PM chainloader (hd32)+1

#GP title FREEDOS GAMES PACK
#GP find --set-root /_iso/DOS/dospak3.img
#GP map --mem /_iso/DOS/dospak3.img (fd0)
#GP map --hook
#GP chainloader (fd0)/kernel.sys