21 - GRUB4DOS TUTORIAL - How to use grub4dos and make pretty menus! - RMPrepUSB

Look! - Over 40 Tutorials‎ > ‎

21 - GRUB4DOS TUTORIAL - How to use grub4dos and make pretty menus!

Unique hits tumblr hit tracking tool

This tutorial is an introduction on how to add the grub4dos bootloader to your boot drive and also how to add a pretty graphical wallpaper.
Grub4dos allows you to make a multiboot drive. It presents you with a menu and then allows you to boot from any OS you have present on the drive.
It can boot from a 'flat file' structure, or from disk images or even ISO files. It can even load images into memory (ram drive) and run the OS from there!
It is used in most of my tutorials and is well worth getting to know if you are interested in making your own multi-boot drives.
The RMPrepUSB download includes grub4dos and will install grub4os onto a usb drive at the click of a button!

If you have never used grub4dos before, I will give you a quick 'How to' intro so you can make a working USB pen drive with which you can experiment.

I don't pretend to be an expert on grub4dos by any means, so if in doubt, please refer to the references in the section below!

References:

Documentation:
Latest grub4dos ReadMe.txt as used with RMPrepUSB (user manual)
http://diddy.boot-land.net/grub4dos/files/README_GRUB4DOS.txt (old)
http://diddy.boot-land.net/grub4dos/files/commands.htm
http://grub4dos.sourceforge.net/wiki/
http://diddy.boot-land.net/grub4dos/Grub4dos.htm
http://diddy.boot-land.net/grub4dos/files/gfxmenu.htm for GFXMenu
Possible errors returned by grub4dos commands - here

Main project page:
https://gna.org/projects/grub4dos/

Download sites:
http://download.gna.org/grub4dos/
http://sarovar.org/projects/grub4dos/
http://sites.google.com/site/grubdos/
ftp://grub4dos.sarovar.org/pub/grub4dos/
https://code.google.com/p/grub4dos-chenall/downloads/list - Chenall latest beta versions

BootLand:
http://www.boot-land.net/forums/?showforum=66 - forums
http://www.boot-land.net/forums/index.php?showtopic=5041 - ISO examples:

Part 1 - Making a bootable USB pen drive

  1. Download and install RMPrepUSB on your Windows XP/Vista/Win7 system (v2.1.620+ recommended as it has the F11 boot emulation feature!)
  2. Insert a USB Flash memory pen drive (any size will do!) into the USB port of your Windows computer and run RMPrepUSB - set the following options:

    1. MAX size
    2. MEMTEST as a label
    3. MS-DOS
    4. FAT16 (or FAT32 if you have >2GB USB drive) + Boot as HDD (2PTNS)
    5. Leave COPY FILES box unticked
    6. Click Prepare Drive to format the USB pen

  3. Click on Install grub4dos - answer 'Yes' to use the MBR option and hit Enter when prompted to copy the grldr file over - or use PBR option if you prefer.
    (You can use MBR or PBR with version 2.1.606 or later versions as it fixes some bugs in grubinst.exe and uses a special version which works better when booting MS-DOS)

  4. Follow the tutorial #20 on how to add MemTest86+ to the USB drive you have just prepared (this is just for an example as Memtest86+ is quick to boot and ideal for testing the grub4dos menu with - if you prefer try tutorial #37 for a FreeDOS USB bootable pen drive).

    You should now have a USB drive with the following 3 files on it:

    grldr
    menu.lst
    memtest.img

Try FlashBoot for 99% Bootability!

RMPrepUSB can make a USB drive bootable, but some BIOSes may have problems. I recommend FlashBoot if you need to create a USB drive that will boot on 99% of systems. Please click here to test a trial version and see if it works for you.

Part 2 - Testing your USB pen drive

We now need to test the USB pen drive to see if it boots. You can either reboot your computer (or use a different computer), change the BIOS boot menu so that the BIOS will boot from the USB pen first and see what happens - OR - you can use an emulator like Qemu - OR if you have RMPrepUSB v2.1.618 or later, simply press the F11 keyboard function key when in RMPrepUSB!

Using Qemu Manager is highly recommended for advanced grub4dos testing - to install it and test your USB pen drive boots correctly, please follow tutorial #15. Once you have Qemu Manager running, you can quickly test your menus without needing to remove your USB drive from the Windows computer you prepared it on. The time spent installing Qemu Manager and creating a virtual machine to boot your USB drive (5 minutes) will save you hours of fiddling about. Be aware though that you need to test your USB bootable drive on as many different PCs as possible:
every PC behaves differently because, unlike bootable CDs, there is no 'standard' for how to treat bootable USB drives. Different BIOSes have different ways, some work, others don't! By using Qemu Manager, you can check that your bootable drive *should* work, even if it does not actually work on your PC when you boot from it for real!

Note: Qemu does not allow BIOS sector writes to the USB drive when it is mapped as a \\PhysicalDriven on your computer (though no error will be reported) - i.e. any physical drive mapped by Qemu will be treated as a readonly device. For this reason, if you are emulating DOS USB drives using Qemu, you may find it does not work as expected when writing files to the USB drive under DOS (once booted under Qemu) or even within grub4dos (e.g. savedefault commands). However, if you set the Qemu 'Do Not Apply Changes to VM Session = Yes' option, then disk writes will at least 'appear' to work for the duration of the Qemu session and your emulated OS should work correctly.
Always test on as many different types of real hardware as you can - Qemu may not work as expected, but real hardware should work!

You should now see a menu screen like this:

When you see this menu - press ENTER and memtest86+ should start to run.

It is possible to spice up this menu. We can change the text and background colour, set a 200 second timeout, a default menu choice if no key is pressed and even add a background wallpaper using a .gz file by using these lines at the top of your menu.lst file (try it!):

#Normal text black with cyan background, Highlighted menu=yellow text with cyan background, Help text=red with light=blue background, Heading is yellow text with white background
color black/cyan yellow/cyan red/light-blue yellow/white
timeout 200
default 0
splashimage=/splash.xpm.gz
foreground=0033FF
background=FF3300

The color statement has the format color NORMAL HIGHLIGHT HELPTEXT HEADING in pairs consisting of foreground/background - valid colours are:
black, blue, green, cyan, red, magenta, brown, light-gray, dark-gray, light-blue, light-green, light-cyan, light-red, light-magenta, yellow and white.

black

blue

brown

cyan

dark-gray

green

light-cyan

light-blue

light-green

light-gray

light-magenta

light-red

magenta

red

white

yellow

Tip: A nice colour scheme can be made by using a light colour for the foreground and the same colour but dark for the background - e.g. light-cyan/cyan or light-green/green.

Lines starting with a # are treated as comments (actually for most grub4dos versions, any starting character except A-Z,a-z,0-9,/(%,white space and + are treated as a comment line character - but the 'official' character for a comment is #). For commands that are above any menu titles, the commands must start on a new line with no space or other character in front of them.
For lines after a title line, white space and graphics characters are ignored unless they follow a command word - e.g. echo.
Commands must be lower case (e.g. root (hd0,0) is OK, but Root (hd0,0) or root (HD0,0) will give an error).

Setting a background image

Note that the menu example above has a 'splashimage' statement. This defines a 14 colour 640x480 pixel image to use as a background image.
For the splashscreen image (if you have used a splashimage command), by default, the foreground colour (all of the menu text and the highlight for the currently selected option) will be white and the background colour (the highlighted text within the currently selected option) will be black - i.e. the color statement is ignored when you have a splashimage statement. You can change text colours however with separate foreground= and background= commands however, which is what the following two lines do in the menu above.

Note grub4dos uses forward slashes for directories. Also note that sometimes it is CaSe SeNsItIvE (e.g. all grub4dos commands/keywords and sometimes when using CD/ISO mapping) - so to be on the safe side always use the same upper and lower case letters to match the files on the USB drive. It is also recommended to use 8.3 filenames (i.e. not long filenames) as you may get problems when booting OS's that do not cope well with long filenames.

You can use 7Zip or Gzip to create a .gz file for your splashimage bitmap or you can use an uncompressed .xmp file instead.
There are 3 important things to know about grub4dos's splash image support.
  • The image needs to be in xpm format (it can be compressed to .gz format)
  • The image needs to be 640x480 in size.
  • The image must have only 14 colors or less.
CONVERSION METHOD 1 (highly recommended for all Windows XP/Vista/7 users - just drag and drop to convert!)
First download and install ImageMagick-6.7.1-7-Q16-windows-dll.exe from http://www.imagemagick.org/download/binaries/ImageMagick-6.7.1-7-Q16-windows-dll.exe (main download page is here).
Next download the grub_consplash_xpmgz zip file from the Downloads - Beta - Tutorials page of this site.
Extract the grub_consplash_xpmgz.cmd file from the ZIP file and copy it to the same folder that you keep your bitmaps in.
Now simply drag and drop any 640x480 .bmp or .png file (can be any colour depth but must be 640x480) onto the grub_consplash_xpmgz.cmd icon and a new xpm.gz file of the same name will be quickly created which has just 14 colours in the same folder that the cmd file is located. The conversion is quite good and probably better than you could do manually using a bitmap editor tool!
Note: if the drag and drop does not work, then you probably have a different version of ImageMagick installed - in this case you will need to change the pathnames by editing the text in the grub_consplash_xpmgz.cmd file using Notepad.

CONVERSION METHOD 2 (for XP - manual)
First find your picture and change it to be 640x480 and 14 colours (use Windows XP MSPaint or your favourite app).
Next save it as a 16 colour .BMP file.
Now get bmp2xpm.exe from the Downloads page or click here and extract and run it. Find your .BMP file (File - Scan for bitmaps) and select it and click on Convert to create your XPM file. Then use 7Zip or Gzip to compress it as a .gz file - or just leave it as an XPM file.

CONVERSION METHOD 3 (I could not get this to save in the correct format - maybe you will have more luck!)
You can also use Gimp to produce the .gz file. You can reduce the colours in Gimp by selecting Image, Mode, Indexed and entering 14 as the maximum colors (if it does not prompt you for the number of colours, select RGB and then select Indexed). Click Convert. Save this file as a XPM, then gzip it. Right-click the file and use 7zip - add to archive - choose .gz from the drop down list beside the name of the file. Under Windows 7, I had some trouble with this method and could not get it to work (maybe you can!).

Click here to see an example grub4dos graphical menu.

Menu numbering and setting a default entry

You can also set a default menu item that will be preselected and also a timeout, try these options as an experiment (the special 2048 byte default file needs to be on your drive and can be obtained from the Beta downloads section).

;the special file 'default' (2048 bytes) must be in the same folder as menu.lst
;when grub4dos loads, the default menu item that was previously set and saved to this file is obtained from this file on first boot/reload
default /default

;set a timeout of 10 seconds before the default menu item is actioned
timeout 10

;default 2
;this will always set the default to the third menu item, so uncomment it if you always want the 3rd item

#reset key map
setkey
#change key map for UK keyboard
setkey at doublequote
setkey doublequote at
setkey tilde bar
setkey numbersign backslash

title 0 reboot with savedefault
savedefault
reboot

title 1 reboot with savedefault
savedefault
reboot

title 2 reboot with 5 second wait for confirmation
savedefault --wait=5
reboot

title 3 reboot with 10 sec wait for confirmation
savedefault --wait=10
reboot

title 4 set default as 2 reboot
savedefault=2
reboot

Note that the user can press '3' to select the 'reboot with a 10 sec wait' menu item. If you have more than 10 entries, grub4dos will still work - e.g. if the user presses '1' and then '2', then menu item 12 will be selected. So you can have up to 100 numbered entries (0-99).

Adding your own menu title

Maybe you do not like the grub4dos version text at the top of the menu?
Would you rather have your title there? If so, try this at the top of your menu.lst file:

color black/cyan yellow/cyan
echo -P:0017 $[0026]PLEASE WAIT
pause --wait=1
write (md)0x220+1 !BAT\necho -n -P:0000 $[0133] --- STEVE'S MENU --- \0
initscript (md)0x220+1

Note: lines 1, 2 and 3 are only for demonstration and can be omitted in your final menu.

Also note that grub4dos commands are case sensitive. The keyword Title or TITLE will not work, it must be title. The same rule applies for other keywords like map and root, etc.
Also the first command word must be at the very start of each line with no space or tab before it.

The lines in the example are explained below:
Line 1 - the color command sets the text and background colours (note American spelling of 'color' and 'gray')
Line 2 - the echo command is supported by later versions of grldr v0.4.5b (as used in RMPrepUSB v2.1.617 and later)
Line 3 - the pause command will wait for a key press, if --wait is used it will only pause for the number of seconds specified or until a key is pressed (Use debug -1 command to suppress the seconds countdown if you prefer).
Line 4 - this line writes a grub4dos batch script to the ramdisk (rd). Grub4dos batch scripts must start with the text !BAT. The text ends with a 0 byte to show the end of the script code.
Line 5 - this line runs the script from the ramdrive that we have just written in line 4

Note: The echo command is only supported in later versions of grub4dos - to test if the echo command works, just type 'c' to get to the command console and then type 'echo fred' in the grub4dos command shell. If it displays 'fred' then the command is supported.

The syntax of echo is:
echo -n -P:XXYY $[ABCD] here lies your message

where -n is optional and means 'do not throw a carriage return at the end of the message'.
-P:XXYY specifies the row and column XX=0-24, YY=0-79 - e.g. -P:0003 is the top row of the screen and four characters in from the left hand side
$[ABCD] specifies the text colour where A=0/1 (where 1 is blinking text), B=0/1(where 1 is bright text), C=0-7 background colour, D=0-7 text colour. (Blinking text did not seem to work for me???).

Colours are: 0=black/grey 1=dark blue, 2=green, 3=aqua, 4=dark red, 5=pink, 6=yellow/brown, 7=grey/white.
Setting B (the second number) to 1 will brighten the text colour.

hence $[0133] is non-flashing bright aqua text on a dark aqua background.

You can write coloured text to more than one position by writing a script which contains more than one echo line as below:

write (md)0x220+1 !BAT\necho -n -P:0000 $[0133] --- MY MENU --- \necho -n -P:2301 READ THIS\0

This writes white text on a black background 'READ THIS' appears at the bottom left of the grub4dos screen.

MENU.LST example (note the help text, which is displayed at the bottom of the menu, is specified in the title line by using \n after the menu text entry)

(note: adding debug 0 to your menu will suppress the menu item number that is displayed at the top-right hand corner of the screen if you use the latest June 2011+ versions of grldr).

debug 0

color black/cyan yellow/cyan
write (md)0x220+1 !BAT\necho -n -P:0000 $[0133] --- MY MENU --- \necho -n -P:2300 READ THIS\0
initscript (md)0x220+1

title 0 Shutdown\nThis will switch off the system
echo $[0173] Shutting down in 2 seconds
pause --wait=2
halt

title 1 Reboot\nThis will reboot the system
echo $[0173] Rebooting in 2 seconds
pause --wait=2
reboot

If you want your menu to have a gap in the menu entries to group the items, you can use:

title
root

to create a blank line in the menu.

You can also create a box within the menu using special graphics characters, like this (cut and paste this into Notepad):

title PLoP Boot Manager\n
find --set-root /HBCD/plpbt.bin
kernel /HBCD/plpbt.bin

title ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
root

title ³ Boot from Hard Drive - Windows XP (NTLDR) ³\n
find --set-root --ignore-floppies --ignore-cd /ntldr
map () (hd0)
map (hd0) ()
map --rehook
find --set-root --ignore-floppies --ignore-cd /ntldr
chainloader /ntldr

title ³ Boot from Hard Drive - Windows Vista/7 (BOOTMGR) ³\n
find --set-root --ignore-floppies --ignore-cd /bootmgr
map () (hd0)
map (hd0) ()
map --rehook
find --set-root --ignore-floppies --ignore-cd /bootmgr
chainloader /bootmgr

title ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
root

title More...
root

Note that ending the title with just \n is used at the end of some lines just to get rid of the edit help text which grub4dos normally displays at the bottom of the menu.

The circled text shows the result when using the special graphics characters.
Note how More... can be used to move the menu list down by a whole page.

Another tip is to write the last menu entry like this:

title ...Back
root

This prompts the user to move to the end of the menu to get back to the first menu item.

Another tip: If you find that you are constantly editing the menu.lst file and then rebooting to test it out, there is an easier way! Make the first menu entry reload the menu.lst file and set the default to 0 so that it is automatically reloaded every 3 seconds. Then all you need do is edit and save the menu.lst file and it will automatically be reloaded and displayed (this is very easy if using an emulator like QEMU under Windows and you have the menu.lst on the USB drive open in Notepad!). You can also test out different splashimages - just overwrite the xpm file with a new version whilst emulating under QEMU.

default 0
timeout 3
splashimage=/mynewimg.xpm.gz

title Reload menu.lst
configfile /menu.lst

#title your other entries here .....

One side affect of using non-boot or non-action commands for gaps in a menu is that these are still numbered by grub4dos (with versions dated before May 9 2011). e.g.

#add debug 0 to suppress the menu number at top right of screen
debug 0
#default will be WinPE Boot = 4 (as menu entries are counted from 0 for the default number)
default 4

title ******** STEVE'S SUPER BOOT DRIVE ********\nPlease user the cursor keys or type a number to select a menu item
root ()

title 1 MS-DOS (AS HDD0)\nBoot to MS-DOS
rootnoverify (hd0,0)
chainloader (hd0,0)/io.sys

title 2 FreeDOS \nBoot to FreeDOS
find --set-root /kernel.sys
chainloader /kernel.sys

title ****** WINPE SECTION ******\n
root()

title 3 Boot winpe
chainloader /bootmgr

then if the user presses the '3' key, they will will get the 4th menu entry (the WINPE menu heading).
The latest chenall build fixes this issue and includes a new improved menu numbering feature grub4dos (code written by me) - just replace the old grldr file with the new version and try it out! You can number your entries consecutively starting from 0 or if you have a blank entry for the first menu title start from 1 (1,2,3,4,etc.), and you can have lots of menu separators or blank titles and the user can still press '9' (for instance) and get the menu item numbered '9' even if it is the 13th menu item (as long as the title line starts with the number 9). Note that if you do not want the user to see a menu item 0, you must still have a first menu entry (entry 0) even if it is just a heading or a blank space (title + root) before you have a menu 1 entry.
If you are having trouble getting the menu items to work and have more than 10 entries, just remember to number the first five or so menus and make sure that you have a menu item (which will be menu item 0) before menu item 1 . Menu item 0 can be a heading or a numbered (0) or un-numbered menu item, but it must exist for the menu system to work properly when the user types the numeric keys.

Also, make sure you have the first numbered menu items (for example if you have 23 menu items, then menu items 0,1 and 2 must be present and numbered). If you want to have menu items numbered non-consecutively (for some strange reason!) - say 1,2,3,10,11,12,20,21,23 - then you must have 24 menu entries in total, so use blank entries at the end of the file to make up the total number of entries to 24 - e.g.

title \n
root ()
title \n
root ()
title \n
root ()
etc.

Passwords

You can also add passwords to the menu. Adding a password before the first title entry will stop users from being able to edit the menu (when booting from the USB drive) or entering the grub4dos command shell unless they type 'p' and then enter a password. Adding a password under each title entry will prompt the user for that password before that particular menu item can be run. You can also encrypt your password. For example:

#the password is steve - type p and then the password to enable grub4dos menu editing - note there are two hyphens in front of md5 - i.e. --md5
password --md5 $1$5$dd0FhBSySgRc8priEU3Dg1

title Test password is admin1 (not encrypted)
password admin1
geometry (hd0,0)

title Test Password is admin, MD5 encrypted
password --md5 $1$6$ftCQWsyP7jK5sUt/JMHMi/
geometry (hd0,0)

Note that adding a password line above the first title line also has the affect of suppressing the default grub4dos menu help text at the bottom of the screen for all menu entries.

You can download the md5crypt program from here to generate your MD5 hash code for your password - run it from the Windows command shell and then cut and paste the 'password --md5 xxxxxxxxxxxx' line into your menu.lst file. You can also generate an MD5 hash code from the grub4dos command shell using the command md5crypt, but you will have to manually type the hash code into your menu file as you cannot cut and paste it from the grub4dos shell window!

So far, so good - but we can do even better than that, time to make a prettier menu...

Part 3 - Adding a graphical menu using GFXboot

Note: before you read this section, unless you really, really want a good looking background (see my menu at the bottom of Part 5 for inspiration!), you should skip this section. Although GFXBoot is very good for providing attractive high resolution and high colour backgrounds, the menu features are limited and are not as flexible as the grub4dos menu system. It is better to get your grub4dos menu fully working before you attempt a pretty GFXMenu as the GFXMneu system is somewhat 'different'!

Using splashimage with grub4dos and having just 14 colours and a low resolution background is a bit limiting, so let's add an 800x600 wallpaper using the add-on GFXMenu component.
  1. Download the file GFXboot.zip from the Beta section and unpack it to a folder on your hard disk (say C:\GFXMenu)
  2. Double-click on the file repack.cmd - you should now see a file called message has been created
  3. Copy the file message to your USB pen drive
  4. Now add the single line

    gfxmenu /message

    to the top of your menu.lst file.

  5. Now try it by booting from it or using Qemu Manager or selecting it in RMPrepUSB and pressing F11 to run QEMU - you should see this:

Pressing F1 will produce some help (mainly for linux users), F2 will allow you to change language but only English is provided in the files I have provided. Pressing F9 will reboot the system and F10 should switch off the system. If the user presses '1' then the first menu item will be selected (note this is different to grub4dos numbering!), if there were more menu entries then they could press '2' for the second entry, etc. If they press [ESC] then they will be asked if they want the old grub4dos style text menu and it will display the black and white menu as in the first screenshot above (or coloured if you used the color or foreground/background commands).

More info on GFXmenu can be found here.

This green background is a bit boring though and we don't really want the F1 and F2 prompts. This is how to change it and have your own picture:
  1. Go to the folder where you downloaded the GFXmenu files (e.g. C:\GFXmenu) and find the \files folder. There are two files in here we can change, back.jpg and gfxboot.cfg.
  2. Find a jpg file that you want for the background. It should be 800 x 600 and 16-bit (65K) colours (though you can use a different resolution by editing gfxboot.cfg). Simply replace the file back.jpg with your one. It MUST be called back.jpg.
    IMPORTANT: Note that you must replace the current back.jpg file - do not add any more files or jpgs or rename the old back.jpg file and leave it there - if you do then gfxmenu may not work!
    Tip: if you have Windows 7 you can search for suitable jpg files in the Explorer search box using type:jpg width:800.
  3. Now to change the menu colours, menu text position and remove the F1 and F2 panel:
    Using Notepad or any other text editor, edit the file files\gfxboot.cfg and uncomment (remove the starting # character) the following entries and change them as below:

    menu_start_x=50
    menu_start_y=50
    hide_help=1
    hide_lang=1

  4. Save the file and double-click on the repack.cmd file.
  5. Copy the new message file that it has just created to your USB drive and overwrite the old one
  6. Now go test it!
You should see that you now have your own wallpaper...

An example of a GFXMenu high quality background (click for a larger picture)

You may find however that the text of your menu items don't show up very well against your new wallpaper if they are a similar colour to the background. In this case you can change the colour of the menu text using these 3 lines (the lines starting with a # are comments and can be omitted as they are ignored):

#Normal text color, use RGB value such as 0xffffff.
menu_text_normal=0xff0000
#Color of selected text
menu_text_select=0x00ff00
#background bar color of selected menu text
menu_bar_color=0xeeeeee

The colours are specified in hexadecimal and are in three groups of two hexadecimal numbers - 0xrrggbb - 0x means that we are specifying a hex number, then we have rrggbb (the first two numbers specify the red brightness, the second the green brightness and the third the blue brightness). Hexadecimal numbers can thus range from 00 (which means 0 in decimal and thus off) to ff (which means 256 in decimal and thus maximum brightness) - here are some colours and their hexadecimal equivalents:

white =     0xffffff  (red+green+blue at max intensity)
black =     0x000000  (all off - no colour at all = black)
red =       0xff0000  (red at maximum + green off + blue off = red)
green =     0x00ff00
blue =      0x0000ff
grey =      0xcccccc
chocolate = 0x993300

for a colour chart and more values, see here.

Tip: You may have noticed that any error will make grub4dos go back to its default menu list. If you want it to always display the GFXMenu (even after an error), you can use the default and timeout commands which don't work in the GFXMenu anyway. Use the following lines at the top of the menu.lst file.

gfxmenu /message
timeout 1
default 0

title Graphical Menu (press ESC - Enter - then ESC quickly for grub4dos text menu)\nDisplay graphical menu automatically
configfile /menu.lst

This will always display the GFXMenu unless you press ESC - then Enter when prompted and then quickly press ESC (or cursor key) to stop the 1 second timeout and stay in the grub4dos menu. Alternatively, omit the title line (but not the other 4 lines of text) and the grub4dos text-based menu will never be displayed - it will always load the GFXMenu, even after an error.

Part 4 - Understanding the grub4dos commands

Now you can try some of the other tutorials on this website and add an extra menu entry into your menu.lst. I would suggest you look at the Ylmf tutorial #17 2nd part - you can add the Ylmf ISO file, and then create the casper-rw file using RMPrepUSB v2.1.605 or later (i.e. follow steps 1, 2 and 5 only). Just pick any tutorial that takes your fancy and add the menu entries into your existing menu.lst file.

For the standard grub4dos menu, you can change the colours, add a timeout, a default choice after the timeout expires (must have the special file 'default' on your drive from the grug4dos package), save the default choice, load a different menu list, set passwords for different menu entries, have a background splash screen, add help text to each menu option (by using \n in the title), include or suppress menu editing and command shell entry. See the reference section at the top of this page.

Note that some of these options are not available when using the GFXMenu menu system - i.e. timeout, passwords, help text, menu editing and command shell entry. I suggest that once you have your GFXMenu background working, you comment out the line for it in your menu.lst so you can more easily debug using the standard grub4dos menu features, and then uncomment it when you have finished.

The instructions above should allow you to make a nice user menu, but what do the commands in the menu.lst file actually do? Lets look at what we have, now that you have added Ylmf to the USB drive:

title memtest86+ v4.10
find --set-root /memtest.img
map /memtest.img (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)
map --floppies=1

title Boot YlmF (Windows Like OS) Non-Persistent\nBoot YlmF from an ISO
find --set-root /Ylmf_OS_3.0.iso
map /Ylmf_OS_3.0.iso (0xff)
map --hook
root (0xff)
kernel /casper/vmlinuz file=/cdrom/preseed/ubuntu.seed boot=casper iso-scan/filename=/ylmf_OS_3.0.iso floppy.allowed_drive_mask=0 splash
initrd /casper/initrd.img

title Boot YlmF (Windows Like OS) Persistent\nBoot YlmF from an ISO and keep any changes in a persistent filesystem
find --set-root /YlmF_OS_3.0.iso
map /YlmF_OS_3.0.iso (0xff)
map --hook
root (0xff)
kernel /casper/vmlinuz
        file=/cdrom/preseed/ubuntu.seed
        boot=casper persistent iso-scan/filename=/YlmF_OS_3.0.iso
           floppy.allowed_drive_mask=0 splash
initrd /casper/initrd.img

What do these commands mean? A detailed explanation can be found here but here is a quick 'essentials' guide.

The first line in each section begins with title xxxxx, and is fairly obvious! It is the text that is presented to the user as a menu item. If you have \n in the title then any text after the \n will appear as the help text at the bottom of the menu list (but not if you have GFXMenu running).

The second line in all these examples is a find --set-root command. This command tells grub4dos to search each drive and look for the file specified in the path specified on all devices in the order: all hard disks - all CDs/DVDs and then all floppies - see here for an explanation. Note that this command can cause problems if you happen to have the file it is looking for on both your hard disk and your USB pen. It is often better to create a file with a unique name (e.g. ABC98732JKL.TAG) on your USB drive and use find --set-root /ABC98732JKL.TAG - that way grub4dos won't find the wrong file! When grub4dos finds the file, it sets the current search path to that path - for instance if you had
find --set-root=/public /public/benji/ABC.TAG
it would set the current drive to the drive where it first found that file - all future references could use / to reference the folder /public. Using the --set-root command is useful because some PCs will boot from a USB pen drive as a hard disk and some will boot to the same pen drive as a floppy - so if you tried to load the file from (fd0)/memtest.img on a system that mapped the USB pen to a hard disk drive (i.e. hd0,0) then it would not find it.
find --set-root --devices=h /bootmgr would find a hard disk partition containing /bootmgr and set that partition as the root drive.
find > /myfile.log - list all drives and put result into the file myfile.log (myfile.log must already exist and be large enough to hold the output - this does not work under QEMU as QEMU does not allow writes unless the Snapshot option is used).

The next line is a map command. grub4dos has some special devices which it can map a file to. Here are the grub4dos device numbers:

(hd0) - first hard disk, hd1=2nd hard disk, etc.
(hd0,0) - first partition on first hard disk
(fd0) - first floppy disk, fd1=2nd hard disk, etc.
(hd32) - virtual CDROM - if you map an ISO to this device it will behave as a CD device - this is the same as device A0 in DOS.
(rd) - ramdrive - mapping a file (inc. iso or .gz file) to this device causes it to be treated as a ramdrive with files
(rd)+1 - access to the file mapped to the ramdrive
(cd) - the real CDROM device
(0xff) - virtual CDROM drive (alternative to hd32 - try this for .iso files if hd32 does not work)
(hd0)+1 - the first sector (MBR) of the first hard drive
(hd0,0)+1 - the first sector (partition boot record) of the first partition of the first hard disk
(bd) - the boot device can be referred to using this device name even if the root device is set to something else (newer versions only)

A detailed explanation of these mapped virtual device names and lots more can be found here. When mapping a device using the map command, +1 refers to the whole partition not just the first sector.

It is important to understand how grub4dos maps your image. If you map an image to a floppy device (fd0/fd1) then grub4dos will expect it to contain boot code at the beginning of the file. If this code tries to access a floppy disk drive, it will be accessing your image file instead. So you can map a 1.44MB floppy disk image (such as memtest.img) to fd0. However, if you try to map memtest.img to (hd32) then grub4dos will treat it as an iso file and map the image as a CD device - hence when the memtest floppy image tries to read sectors from the 'floppy disk' it fails to boot. Similarly, if you try to map a binary program instead of a floppy disk image as (fd0) it will fail to load.

The map command will cause the file specified (or device) to be treated as a virtual device - any access to the device will cause a block seek to the correct place in the file - for this reason the file must be contiguous (all in sequential clusters). For ISO files you may get a 'File not contiguous' error reported by grub4dos. This often happens when you copy, edit and delete files on the USB drive a lot and then copy over an ISO file. The best way to fix this is to copy all the files off of the USB drive, reformat the drive and then copy them all back again. Another way to get around this, is to use the map --mem command - if you use this command the ISO file does not need to be contiguous (but it will be loaded into memory by grub4dos which will be slower and require the system to have more memory). For instance, the line

map /YlmF_OS_3.0.iso (0xff) || map --mem /YlmF_OS_3.0.iso (0xff)

will attempt to map the iso file, but if it fails because the iso file is not contiguous, grub4dos will then try to load it into memory as one contiguous file and then map the device 0xff to it. The || symbol means OR, so the command is 'map the iso directly as device (0xff) OR if this fails then load it into memory and map it as device (0xff)'.

The grub4dos map command also supports .gz (gzip) compressed files (which you can make using 7Zip or Gzip). This is useful if you are short of space on your USB drive and you have ISO files which will compress well.

It is also important to understand that grub4dos works by patching BIOS interrupts, so real-mode Operating systems like MS-DOS and FreeDOS will work well when the map command is used. However, once a protected mode Operating System like Windows XP or linux runs, it loads it's own device drivers and these do not use the BIOS at all. This means that as soon as the Operating System protected-mode kernel is loaded, all of the grub4dos mapping is lost - Windows or linux will see only physical devices and not the virtual devices created by the grub4dos map commands (though there are some special features in grub4dos to make it work better for OS's such as linux that can boot from a ram drive).

The next line is map --hook. This is where any previous map commands actually become activated. The previous map device commands check that a file is contiguous or loads it into memory if the --mem parameter is specified but any attempt to access the device will fail until the BIOS interrupts are actually 'hooked' to their new virtual drives or files. The map --hook command changes the interrupt pointers so that an access to the virtual device will actually access the file or device specified by the previous map (device) commands.

The next line (in the Ylmf menu) is the root (0xff) command, this sets the root device to the file that was chainloaded, so that any file path to / , will access the 0xff device. You could instead just use (0xff)/ to specify the same folder, however the following command lines (kernel, etc.) might not be able to understand the (0xff) device name. The kernel command is an instruction to load a linux kernel which expects to be loaded into memory in a certain way; also we can pass parameters and values to the kernel by using a command line type syntax on the same menu line which will get passed to the linux kernel.

The final line in the Ylmf menu is initrd, this is an initial ramdrive which is a temporary filesystem used in the boot process of the linux kernel - initrd and initramfs are both commonly used to make preparations before the real root filesystem can be mounted.

For the memtest menu.lst entries we have:

chainloader (fd0)+1
rootnoverify (fd0)
map --floppies=1

chainloader is a command to load a file or a disk sector into memory and set the code execution start point to the start of that memory location where it loaded the code to. In this case it is set to the first partition of the virtual floppy disk drive (which is the memtest86.img file). As the memtest86.img file is a 1.44MB floppy disk image, it will load the first floppy disk boot sector. As we have mapped the whole file as a virtual floppy disk, when that boot sector code executes, it will try to access floppy disk sectors, but grub4dos has just mapped the floppy disk to the memtest86.img file instead, so the boot code will actually read sectors from the memtest86.img file when it asks to read sectors from the 'floppy disk'. Add --force if grub4dos gives an error due to a bad signature or incorrect format.

rootnoverify (fd0) sets the current device root to the virtual floppy and does not verify or check if the device is a valid 'disk' with valid geometry or mount the device. In this example, this line is actually not needed and the USB drive will boot to memtest without this line. Using root (fd0) would fail though (Error 17: cannot mount selected partition).

map --floppies=1 - this tells grub4dos that the BIOS must report just one floppy is present (the mapped one) to the OS - this can usually be omitted unless you are booting to DOS or some OS which may enumerate floppy drives.

When grub4dos finishes a sequence of commands in a menu.lst and finds the end of file or a new title command, it automatically runs the 'boot' command which then transfers CPU execution to the code loaded into memory (either by a chainloader command or an initrd command).

Multiple menus

With grub4dos, you can have multiple menus. The menu shown below will allow the user to load one of three other menus.

title DOS Boot menu\nChoose to boot MS-DOS or FreeDOS in a variety of ways
configfile /dosmenu.lst

title linux Boot menu\nChoose from a variety of different linux distros
configfile /linuxmenu.lst

title Install Windows\nChoose to install and version of Windows onto your hard disk
configfile /winmenu.lst

In these three sub-menus, you can then also include a 'main menu' menu entry such as:

title Return to Main Menu\nGo back to the main menu
find --set-root /AABBCC.TAG || find --set-root /menu.lst
configfile ()/menu.lst

Note that as the sub-menus may have changed the drive mapping, the above 'return to main menu' entry tries to find the original USB boot drive by looking for the special tag file AABBCC.TAG which you should place on the grub4dos boot drive. As a 'default' backup, if it cannot find AABBCC.TAG anywhere, then it looks for menu.lst instead (and we hope you don't have a file called menu.lst on the internal hard disk!).

Using variables in grub4dos menus
Recent versions of grub4dos (see near end of the grub4dos readme file for more details) also have the ability to set and use variables. Consider the following menu.lst

title Boot from any hard disk partition
errorcheck off ## ignore errors in case no hd1
geometry (hd0) ## show hd0 partitions
echo
geometry (hd1) ## show hd1 partitions
errorcheck on ## don't ignore errors now
set /p HD=Which hard disk do you want to boot from (0 or 1):
set v=0
if "%HD%"=="0" set v=1
if "%HD%"=="1" set v=1
if "%v%"=="0" configfile /menu.lst
set /p PTN=Which partition do you want to boot from on hd%HD% (0 or 1):
set v=0
if "%PTN%"=="0" set v=1
if "%PTN%"=="1" set v=1
if "%v%"=="0" configfile /menu.lst
echo Booting from (hd%HD%,%PTN%)
root (hd%HD%,%PTN%)
chainloader (hd%HD%,%PTN%)+1
boot

title Boot any ISO
ls /ISO/
set /p MYISO=Which ISO do you want to boot?
ls /ISO/%MYISO% || echo ISO %MYISO% NOT FOUND! && configfile /menu.lst
map /ISO/%MYISO% (0xff)
map --hook
chainloader (0xff)

# Note:This example only works if you are using a version of grub4dos that treats ## as a comment delimiter
# If your grub4dos does not like it, remove the ## characters and all text after it
# version 2.1.623 contains grub4dos with this in-line comment feature

title test variables and inline comments feature of grub4dos
debug off ## don't show debug info
set A=1## set the variable A to 1
set B=3## set the variable B to 3
set /A C=%B% + %A% ## Add the two together /A means arithmetic
echo %A% + %B% = %C% ## show the sum and result
pause ## pause for the user to see
set GG=## clear GG variable
set /l GG=Aa## convert to lower case and put in GG variable
echo %GG% - should echo aa## should be lower case aa
set GG=## clear GG variable if nothing after the = sign
set /u GG=Aa## set to uppercase
echo %GG% = should echo AA
set GG=## clear GG variable
set /p /u GG=Type in Aa here: ## prompt user to type and convert to uppercase
if %GG%@==@ echo YOU DID NOT TYPE ANYTHING IN! && pause
echo %GG% should echo AA## it should be all uppercase
if "%GG%"=="AA" echo What you typed was converted to uppercase correctly!
pause
echo We can display words inside percent signs, e.g. %^GG% by using the ^ symbol anywhere inside it
pause
configfile /menu.lst ## reload this menu
boot ## include an action command so we can select this in the menu

Output from above test variables menu

Note: The version of grldr in RMPrepUSB 2.1.626 treats ' # ' or '## ' as the start of an inline comment. If you want to have the # symbol in a menu title, use \x23 - e.g. title \x23\x23##### My title \x23\x23#####. Also note that the \x23 cannot be used in echo commands, so ' # ' or '## ' cannot be printed using echo commands.

The new command syntax for grub4dos variables is:

set [/p] [/a|/A] [/l|/u] [VARIABLE=[STRING]] you can set or clear a variable or prompt for one using /p, /a does arithmetic operations and /u converts to uppercase or /l to lower
if [/I] [NOT] STRING1==STRING2 [COMMAND] where I means case Insensitive
if [NOT] exist VARIABLE|FILENAME [COMMAND] you can check for the existence of a variable or filename

e.g.
set /p /u ask=Enter iso filename WITH NO EXTENSION (e.g. win7pro32 ) :
echo %ask% && pause

will convert the answer typed by the user ial file 'default' on your drive from the grug4dos package), save the default choice, load a different menu list, set passwords for different menu entries, have a background splash screen, add help text to each menu option (by using \n in the title), include or suppress menu editing and command shell entry. See the reference section at the top of this page.

Note that some of these options are not available when using the GFXMenu menu system - i.e. timeout, passwords, help text, menu editing and command shell entry. I suggest that once you have your GFXMenu background working, you comment out the line for it in your menu.lst so you can more easily debug using the standard grub4dos menu features, and then uncomment it when you have finished.

The instructions above should allow you to make a nice user menu, but what do the commands in the menu.lst file actually do? Lets look at what we have, now that you have added Ylmf to the USB drive:

title memtest86+ v4.10
find --set-root /memtest.img
map /memtest.img (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)
map --floppies=1

title Boot YlmF (Windows Like OS) Non-Persistent\nBoot YlmF from an ISO
find --set-root /Ylmf_OS_3.0.iso
map /Ylmf_OS_3.0.iso (0xff)
map --hook
root (0xff)
kernel /casper/vmlinuz file=/cdrom/preseed/ubuntu.seed boot=casper iso-scan/filename=/ylmf_OS_3.0.iso floppy.allowed_drive_mask=0 splash
initrd /casper/initrd.img

title Boot YlmF (Windows Like OS) Persistent\nBoot YlmF from an ISO and keep any changes in a persistent filesystem
find --set-root /YlmF_OS_3.0.iso
map /YlmF_OS_3.0.iso (0xff)
map --hook
root (0xff)
kernel /casper/vmlinuz
        file=/cdrom/preseed/ubuntu.seed
        boot=casper persistent iso-scan/filename=/YlmF_OS_3.0.iso
           floppy.allowed_drive_mask=0 splash
initrd /casper/initrd.img

What do these commands mean? A detailed explanation can be found here but here is a quick 'essentials' guide.

The first line in each section begins with title xxxxx, and is fairly obvious! It is the text that is presented to the user as a menu item. If you have \n in the title then any text after the \n will appear as the help text at the bottom of the menu list (but not if you have GFXMenu running).

The second line in all these examples is a find --set-root command. This command tells grub4dos to search each drive and look for the file specified in the path specified on all devices in the order: all hard disks - all CDs/DVDs and then all floppies - see here for an explanation. Note that this command can cause problems if you happen to have the file it is looking for on both your hard disk and your USB pen. It is often better to create a file with a unique name (e.g. ABC98732JKL.TAG) on your USB drive and use find --set-root /ABC98732JKL.TAG - that way grub4dos won't find the wrong file! When grub4dos finds the file, it sets the current search path to that path - for instance if you had
find --set-root=/public /public/benji/ABC.TAG
it would set the current drive to the drive where it first found that file - all future references could use / to reference the folder /public. Using the --set-root command is useful because some PCs will boot from a USB pen drive as a hard disk and some will boot to the same pen drive as a floppy - so if you tried to load the file from (fd0)/memtest.img on a system that mapped the USB pen to a hard disk drive (i.e. hd0,0) then it would not find it.
find --set-root --devices=h /bootmgr would find a hard disk partition containing /bootmgr and set that partition as the root drive.
find > /myfile.log - list all drives and put result into the file myfile.log (myfile.log must already exist and be large enough to hold the output - this does not work under QEMU as QEMU does not allow writes unless the Snapshot option is used).

The next line is a map command. grub4dos has some special devices which it can map a file to. Here are the grub4dos device numbers:

(hd0) - first hard disk, hd1=2nd hard disk, etc.
(hd0,0) - first partition on first hard disk
(fd0) - first floppy disk, fd1=2nd hard disk, etc.
(hd32) - virtual CDROM - if you map an ISO to this device it will behave as a CD device - this is the same as device A0 in DOS.
(rd) - ramdrive - mapping a file (inc. iso or .gz file) to this device causes it to be treated as a ramdrive with files
(rd)+1 - access to the file mapped to the ramdrive
(cd) - the real CDROM device
(0xff) - virtual CDROM drive (alternative to hd32 - try this for .iso files if hd32 does not work)
(hd0)+1 - the first sector (MBR) of the first hard drive
(hd0,0)+1 - the first sector (partition boot record) of the first partition of the first hard disk
(bd) - the boot device can be referred to using this device name even if the root device is set to something else (newer versions only)

A detailed explanation of these mapped virtual device names and lots more can be found here. When mapping a device using the map command, +1 refers to the whole partition not just the first sector.

It is important to understand how grub4dos maps your image. If you map an image to a floppy device (fd0/fd1) then grub4dos will expect it to contain boot code at the beginning of the file. If this code tries to access a floppy disk drive, it will be accessing your image file instead. So you can map a 1.44MB floppy disk image (such as memtest.img) to fd0. However, if you try to map memtest.img to (hd32) then grub4dos will treat it as an iso file and map the image as a CD device - hence when the memtest floppy image tries to read sectors from the 'floppy disk' it fails to boot. Similarly, if you try to map a binary program instead of a floppy disk image as (fd0) it will fail to load.

The map command will cause the file specified (or device) to be treated as a virtual device - any access to the device will cause a block seek to the correct place in the file - for this reason the file must be contiguous (all in sequential clusters). For ISO files you may get a 'File not contiguous' error reported by grub4dos. This often happens when you copy, edit and delete files on the USB drive a lot and then copy over an ISO file. The best way to fix this is to copy all the files off of the USB drive, reformat the drive and then copy them all back again. Another way to get around this, is to use the map --mem command - if you use this command the ISO file does not need to be contiguous (but it will be loaded into memory by grub4dos which will be slower and require the system to have more memory). For instance, the line

map /YlmF_OS_3.0.iso (0xff) || map --mem /YlmF_OS_3.0.iso (0xff)

will attempt to map the iso file, but if it fails because the iso file is not contiguous, grub4dos will then try to load it into memory as one contiguous file and then map the device 0xff to it. The || symbol means OR, so the command is 'map the iso directly as device (0xff) OR if this fails then load it into memory and map it as device (0xff)'.

The grub4dos map command also supports .gz (gzip) compressed files (which you can make using 7Zip or Gzip). This is useful if you are short of space on your USB drive and you have ISO files which will compress well.

It is also important to understand that grub4dos works by patching BIOS interrupts, so real-mode Operating systems like MS-DOS and FreeDOS will work well when the map command is used. However, once a protected mode Operating System like Windows XP or linux runs, it loads it's own device drivers and these do not use the BIOS at all. This means that as soon as the Operating System protected-mode kernel is loaded, all of the grub4dos mapping is lost - Windows or linux will see only physical devices and not the virtual devices created by the grub4dos map commands (though there are some special features in grub4dos to make it work better for OS's such as linux that can boot from a ram drive).

The next line is map --hook. This is where any previous map commands actually become activated. The previous map device commands check that a file is contiguous or loads it into memory if the --mem parameter is specified but any attempt to access the device will fail until the BIOS interrupts are actually 'hooked' to their new virtual drives or files. The map --hook command changes the interrupt pointers so that an access to the virtual device will actually access the file or device specified by the previous map (device) commands.

The next line (in the Ylmf menu) is the root (0xff) command, this sets the root device to the file that was chainloaded, so that any file path to / , will access the 0xff device. You could instead just use (0xff)/ to specify the same folder, however the following command lines (kernel, etc.) might not be able to understand the (0xff) device name. The kernel command is an instruction to load a linux kernel which expects to be loaded into memory in a certain way; also we can pass parameters and values to the kernel by using a command line type syntax on the same menu line which will get passed to the linux kernel.

The final line in the Ylmf menu is initrd, this is an initial ramdrive which is a temporary filesystem used in the boot process of the linux kernel - initrd and initramfs are both commonly used to make preparations before the real root filesystem can be mounted.

For the memtest menu.lst entries we have:

chainloader (fd0)+1
rootnoverify (fd0)
map --floppies=1

chainloader is a command to load a file or a disk sector into memory and set the code execution start point to the start of that memory location where it loaded the code to. In this case it is set to the first partition of the virtual floppy disk drive (which is the memtest86.img file). As the memtest86.img file is a 1.44MB floppy disk image, it will load the first floppy disk boot sector. As we have mapped the whole file as a virtual floppy disk, when that boot sector code executes, it will try to access floppy disk sectors, but grub4dos has just mapped the floppy disk to the memtest86.img file instead, so the boot code will actually read sectors from the memtest86.img file when it asks to read sectors from the 'floppy disk'. Add --force if grub4dos gives an error due to a bad signature or incorrect format.

rootnoverify (fd0) sets the current device root to the virtual floppy and does not verify or check if the device is a valid 'disk' with valid geometry or mount the device. In this example, this line is actually not needed and the USB drive will boot to memtest without this line. Using root (fd0) would fail though (Error 17: cannot mount selected partition).

map --floppies=1 - this tells grub4dos that the BIOS must report just one floppy is present (the mapped one) to the OS - this can usually be omitted unless you are booting to DOS or some OS which may enumerate floppy drives.

When grub4dos finishes a sequence of commands in a menu.lst and finds the end of file or a new title command, it automatically runs the 'boot' command which then transfers CPU execution to the code loaded into memory (either by a chainloader command or an initrd command).

Multiple menus

With grub4dos, you can have multiple menus. The menu shown below will allow the user to load one of three other menus.

title DOS Boot menu\nChoose to boot MS-DOS or FreeDOS in a variety of ways
configfile /dosmenu.lst

title linux Boot menu\nChoose from a variety of different linux distros
configfile /linuxmenu.lst

title Install Windows\nChoose to install and version of Windows onto your hard disk
configfile /winmenu.lst

In these three sub-menus, you can then also include a 'main menu' menu entry such as:

title Return to Main Menu\nGo back to the main menu
find --set-root /AABBCC.TAG || find --set-root /menu.lst
configfile ()/menu.lst

Note that as the sub-menus may have changed the drive mapping, the above 'return to main menu' entry tries to find the original USB boot drive by looking for the special tag file AABBCC.TAG which you should place on the grub4dos boot drive. As a 'default' backup, if it cannot find AABBCC.TAG anywhere, then it looks for menu.lst instead (and we hope you don't have a file called menu.lst on the internal hard disk!).

Using variables in grub4dos menus
Recent versions of grub4dos (see near end of the grub4dos readme file for more details) also have the ability to set and use variables. Consider the following menu.lst

title Boot from any hard disk partition
errorcheck off ## ignore errors in case no hd1
geometry (hd0) ## show hd0 partitions
echo
geometry (hd1) ## show hd1 partitions
errorcheck on ## don't ignore errors now
set /p HD=Which hard disk do you want to boot from (0 or 1):
set v=0
if "%HD%"=="0" set v=1
if "%HD%"=="1" set v=1
if "%v%"=="0" configfile /menu.lst
set /p PTN=Which partition do you want to boot from on hd%HD% (0 or 1):
set v=0
if "%PTN%"=="0" set v=1
if "%PTN%"=="1" set v=1
if "%v%"=="0" configfile /menu.lst
echo Booting from (hd%HD%,%PTN%)
root (hd%HD%,%PTN%)
chainloader (hd%HD%,%PTN%)+1
boot

title Boot any ISO
ls /ISO/
set /p MYISO=Which ISO do you want to boot?
ls /ISO/%MYISO% || echo ISO %MYISO% NOT FOUND! && configfile /menu.lst
map /ISO/%MYISO% (0xff)
map --hook
chainloader (0xff)

# Note:This example only works if you are using a version of grub4dos that treats ## as a comment delimiter
# If your grub4dos does not like it, remove the ## characters and all text after it
# version 2.1.623 contains grub4dos with this in-line comment feature

title test variables and inline comments feature of grub4dos
debug off ## don't show debug info
set A=1## set the variable A to 1
set B=3## set the variable B to 3
set /A C=%B% + %A% ## Add the two together /A means arithmetic
echo %A% + %B% = %C% ## show the sum and result
pause ## pause for the user to see
set GG=## clear GG variable
set /l GG=Aa## convert to lower case and put in GG variable
echo %GG% - should echo aa## should be lower case aa
set GG=## clear GG variable if nothing after the = sign
set /u GG=Aa## set to uppercase
echo %GG% = should echo AA
set GG=## clear GG variable
set /p /u GG=Type in Aa here: ## prompt user to type and convert to uppercase
if %GG%@==@ echo YOU DID NOT TYPE ANYTHING IN! && pause
echo %GG% should echo AA## it should be all uppercase
if "%GG%"=="AA" echo What you typed was converted to uppercase correctly!
pause
echo We can display words inside percent signs, e.g. %^GG% by using the ^ symbol anywhere inside it
pause
configfile /menu.lst ## reload this menu
boot ## include an action command so we can select this in the menu

Output from above test variables menu

Note: The version of grldr in RMPrepUSB 2.1.626 treats ' # ' or '## ' as the start of an inline comment. If you want to have the # symbol in a menu title, use \x23 - e.g. title \x23\x23##### My title \x23\x23#####. Also note that the \x23 cannot be used in echo commands, so ' # ' or '## ' cannot be printed using echo commands.

The new command syntax for grub4dos variables is:

set [/p] [/a|/A] [/l|/u] [VARIABLE=[STRING]] you can set or clear a variable or prompt for one using /p, /a does arithmetic operations and /u converts to uppercase or /l to lower
if [/I] [NOT] STRING1==STRING2 [COMMAND] where I means case Insensitive
if [NOT] exist VARIABLE|FILENAME [COMMAND] you can check for the existence of a variable or filename

e.g.
set /p /u ask=Enter iso filename WITH NO EXTENSION (e.g. win7pro32 ) :
echo %ask% && pause

will convert the answer typed by the user into uppercase.

Another example:

debug off
set a=2
set /A b = %a% + 4
echo %b%
set /a b = %a% * 4
echo %b%
pause

will print 0x6 and 8 as /A is used to convert the answer to hex notation and /a is used for decimal arithmetic. The debug off stops the result of the set calculation from being displayed on the screen.

Notes:
You can replace a command or whole command line using a variable, but you cannot replace some parts, such as a drive token like (hd0,0), with a variable - e,g, root (hd0,%myvalue%) does not work.
Variables are case sensitive, set a=5, set A=6 - A and a are different variables with different values.

grub4dos undocumented commands

Later versions of grub4dos (0.4.5b) have enhanced cat parameters which allow you to replace strings. The help cat command does not list them all though, even though they are supported!

The cat command has these parameters:
--hex display file contents in hex - e.g. display MBR using cat --hex --length=512 (hd0)+1
--hex=h if h=1 then display in hex else display as text
--skip=S number of bytes to skip - e.g. cat --hex --length=512 --skip=500 /menu.lst would list 12 bytes starting at byte 1F4
--length=L number of bytes/characters to display (ignored if locate is used)
--locate=STRING find a string in the file (max.16 characters allowed)
--locate-align=A look for a STRING on an alignment boundary - e.g. --locate-align=4 will look for the string at positions 0,4,8,12,etc...
--replace=R replaces STRING with another string (max=16 chars).
Note: cat --locate=color red/green --replace=color white will result in color whitereen. The command cat --locate=c --replace=coloR --number=1 /menu.lst will change color to coloR
--number=N number of replacements to be made or locations to be listed

One use is to change the contents of a file (via byte replacement).

ls (0xff)/ && root (0xff)
ls (0xff)/I386/ && cat --locate=rdisk(1) --replace=rdisk(2) (0xff)/I386/TXTSETUP.SIF
ls (0xff)/AMD64/ && cat --locate=rdisk(1) --replace=rdisk(2) (0xff)/AMD64/TXTSETUP.SIF
ls (0xff)/ && chainloader (0xff)/I386/SETUPLDR.BIN
ls (0xff)/ || rootnoverify (hd0)
ls (0xff)/ || chainloader (hd0)+1

Note: cat --replace will only work if writes to the target device is allowed. Thus changing a menu.lst file under QEMU will not work as QEMU does not allow writes to a mounted physical device.
Tip: To prevent grub4dos listng hex positions use debug 0 in the menu.

Part 5 - Troubleshooting

grub4dos has very powerful and useful menu editing and command line features. To try this, let us boot from our USB pen and select the Memtest86 menu item - but don't press [Enter] - instead press 'e' for edit (note you must be in the grub4dos menu system, if in the GFXmenu system, press the [ESC] key to get to the grub4dos menu). The menu lines for the Memtest86 menu will be displayed when e is pressed. You can now edit these lines and add or delete lines and try to fix any problems. Any changes you make however will NOT permanently change the menu.lst file, the changes are only temporary. There is help text below the edit window to help you to edit the menu entries.

Often though, editing the menu does not help much as you need to see what is going on when each of the menu commands run and perhaps 'single-step' through them. Press 'c' for command line interpreter and you will be given a command prompt. You can now type in the commands one by one and observe what happens. Entering a partial command and hitting the [TAB] key will often complete the command or give a list of possible valid values to complete the command. Remember to reboot each time you try a new set of commands and try to boot (type 'boot' from the command line to try to boot). Some useful commands to help debug your menu items are:
help - to see a list of commands
help map - to see the syntax of map command
ls - list files and folders at the current root location
map --status - displays what devices are present and if they are 'hooked' by grub4dos
map ( [TAB] - will print all possible disks that it can see - e.g. Possible disks are : hd0 hd1 rd cd
root - displays the root device - e.g. (hd0,0): Filesystem type is fat, partition type 0x0c
find (hd0, [TAB] - shows all possible partitions on first hard disk
geometry - show current drive geometry
geometry --tune - alter current drive geometry reported by BIOS to match that of MBR
find +1 - list all devices with a known filesystem
find - list all devices
boot - boot using the device/file previously selected

Example debug commands and there results (click to enlarge)

for a full list of commands in the latest version included with RMPrepUSB - see here.

Tip: to aid debugging, it is good practice to use the following two lines at the beginning of each menu item to undo any previous drive mappings (though it can be quite slow)

map --unhook
map --unmap=0:0xff

If booting to DOS or linux, you may get better results (helps prevent flashing cursor syndrome!) using the geometry tune and sync commands to ensure the correct disk geometry - e.g.

title More reliable MS-DOS boot on any system
find --set-root /io.sys
geometry --tune
geometry --sync
chainloader /io.sys

Another tip is to turn on debugging using

#case sensitive!
debug on

You have a choice of debug on(2), off (0) or normal (1) or a number. Normal is the default. A value of -1 tends to turn off any normal extra messages such as timeout countdowns or information messages. The command debug status displays the current debug level number.

Another trick for better results is to use && and || (which means AND and OR) - here is an example -->

title here is a test
#turn off debug and prevent countdown timer from displaying
debug -1
ls /my.iso && clear && pause --wait=3 I found /my.iso!
#now turn debug on again
debug normal
(put more commands here)

This says 'list /my.iso to the console - if it was there then clear the screen - if that worked output the message 'I found /my.iso' and wait for 3 seconds or until a key is pressed'.

The command pause --test-key will output the scancode of the next key that you press.

To have a menu entry which takes you to the command line shell, use 'commandline' in a menu entry - this may be useful for debugging:

title Goto grub4dos command line
(some command)
(some command)
(some command)
#now drop to command line and try a few things before typing boot to test booting...
find
ls /
commandline

Another useful menu entry which will reload your menu.lst file after you have just changed it (e.g. whilst running under an emulator and to save rebooting under the emulator) is:

title Reload menu.lst
configfile /menu.lst

errorcheck off will prevent grub4dos aborting if it finds an error with any command. This means you can try several commands in a row until one works:

errorcheck off
find --set-root --ignore-floppies --ignore-cd /boot/grub/menu.lst && configfile /boot/grub/menu.lst
find --set-root --ignore-floppies --ignore-cd /grub/menu.lst && configfile /grub/menu.lst

Single-Stepping
If grub4dos has trouble booting or finding your menu.lst, then as soon as it starts to boot, keep hitting the INSERT key. Grub4dos will then be in single-step mode and you can see error messages which are normally hidden. Hit a key to execute each next step until you see your menu:

Want to know if your USB drive is booting as a hard disk or floppy?

title who am I?
checkrange 0x80 read 0x8280 && pause --wait=3 I am Hard Disk 0
checkrange 0x81 read 0x8280 && pause --wait=3 I am Hard Disk 1
checkrange 0x82 read 0x8280 && pause --wait=3 I am Hard Disk 2
checkrange 0x00 read 0x8280 && pause --wait=3 I am Floppy Disk 0
checkrange 0x01 read 0x8280 && pause --wait=3 I am Floppy Disk 1
reboot

This works because the BIOS keeps the boot device number at 0x8280 (the value held there can be: 80 hex is hard disk 0, 81h is hard disk 1, 0 is floppy disk 0, etc.).
You can also use it like this to always boot from your hard disk, even if the USB drive booted as a floppy on one system and a hard disk on another:

checkrange 0x80 read 0x8280 && map (hd1) (hd0)
checkrange 0x80 read 0x8280 && map --hook
chainloader (hd0)+1

These menu items mean: if the USB booted as hd0 then map my real hard disk as hd0 - now boot from hd0.
So if the UFD booted as a floppy the system will boot from hard disk (hd0), if the USB drive booted as hd0, grub4dos will map hd1 (the hard drive) as hd0 and then boot from hd0 (the hard disk).

Or if you always want your USB drive to boot as a floppy disk on any system...

title Always boot from USB AS A FLOPPY
checkrange 0x80 read 0x8280 && map (hd0,0)+1 (fd0)
checkrange 0x80 read 0x8280 && map (hd1) (hd0)
checkrange 0x80 read 0x8280 && map --hook
chainloader (fd0)+1
rootnoverify (fd0)
map --floppies=1
map --harddrives=1
boot

WENV

Wenv (available on Beta downloads page) is a grub4dos utility (a program) that you can run under the grub4dos environment. It is just like an executable that you would run under DOS (e.g. find.exe) but it runs under grub4dos. It allows you to use environment variables in your menu.lst files or to run a script file which can execute grub4dos commands. For instance....

(Note: the line numbers in the menu below are not normally present in a grub4dos menu.lst - they have been added for reference purposes only):

  1. title Install Windows 7 64-bit Enterprise Edition\nRun the Windows install DVD to install a copy of Windows to your hard disk
  2. /Imdisk/wenv set iso=/iso/en_windows_7_enterprise_with_sp1_x64_dvd_620201.iso
  3. find --set-root/ImDisk/myiso.cmd
  4. dd if=()/ImDisk/au.xml of=()/AutoUnattend.xml
  5. dd if=()/ImDisk/cr.txt of=()/ImDisk/myiso.cmd
  6. /ImDisk/wenv call write ()/ImDIsk/myiso.cmd SET MYISO=${iso}\r\n
  7. /ImDisk/wenv call map ${iso} (0xff)
  8. map (hd0) (hd1)
  9. map (hd1) (hd0)
  10. map --hook
  11. chainloader (0xff)
Note that line 2 sets the grub4dos environment variable 'iso' to the path of the ISO file by running the wenv executable with parameters.
In line 6 and line 7 we can use this variable value by substituting it with ${iso}.
Note that wenv needs to have a full path as grub4dos needs to find the wenv file which is in the /ImDisk folder in this example.
Also note that to use environment variables and wenv with grub4dos commands, we need to 'call' the grub4dos command, this why lines 6 and 7 start with '/ImDisk/wenv call'

If you copy the grub4dos executable file wenv (available on Beta downloads page) to the USB drive /ImDisk folder, you can make the menu.lst easier to edit and add more ISO files.
The Wenv download zip file also includes an English translated text file which I have added for you to study.

WENV list of commands currently supported:

SET to set/change/add/delete/display variables
GET display variable/variables and get length of the variable in _GET internal variable
FOR similar to the windows shell FOR cmd instruction
CALC simple calculator (priority from left to right, does not support brackets)
ECHO Display a message or variable to the screen
READ a file and run the commands inside - similar to a .cmd batch file (must use WENV supported commands) also supports parameters.
CHECK check if an equation is true or false, if it returns true a command can be executed
RESET clear/reset a variable
CALL call the grub4dos shell to execute a grub4dos command

Note: SET, GET, FOR, RESET, CALC and ECHO are largely redundant now as similar functions are built into the latest grub4dos versions from chenall (included in RMPrepUSB).

For instance, if you type /wenv set in the grub4dos command console window, then wenv will display all current grub4dos environment variables.

Here is another example of how you can use wenv (note: this time wenv is located in the root of the drive and not in the ImDisk folder):

title Specify an iso file to run
# list all files in the /boot/imgs folder so the user can see them
ls /boot/imgs/
echo
# Ask user which iso they want (name is converted to uppercase as $U is specified)
/WENV set ask=$U,$input,Enter iso name with no extension (e.g. dban) :
/WENV get ask || echo No iso file specified! && configfile /menu.lst
clear
/WENV echo Loading /boot/imgs/${ask}.iso - please wait ...
debug off
set a=2
set /A b = %a% + 4
echo %b%
set /a b = %a% * 4
echo %b%
pause

will print 0x6 and 8 as /A is used to convert the answer to hex notation and /a is used for decimal arithmetic. The debug off stops the result of the set calculation from being displayed on the screen.

Notes:
You can replace a command or whole command line using a variable, but you cannot replace some parts, such as a drive token like (hd0,0), with a variable - e,g, root (hd0,%myvalue%) does not work.
Variables are case sensitive, set a=5, set A=6 - A and a are different variables with different values.

grub4dos undocumented commands

Later versions of grub4dos (0.4.5b) have enhanced cat parameters which allow you to replace strings. The help cat command does not list them all though, even though they are supported!

The cat command has these parameters:
--hex display file contents in hex - e.g. display MBR using cat --hex --length=512 (hd0)+1
--hex=h if h=1 then display in hex else display as text
--skip=S number of bytes to skip - e.g. cat --hex --length=512 --skip=500 /menu.lst would list 12 bytes starting at byte 1F4
--length=L number of bytes/characters to display (ignored if locate is used)
--locate=STRING find a string in the file (max.16 characters allowed)
--locate-align=A look for a STRING on an alignment boundary - e.g. --locate-align=4 will look for the string at positions 0,4,8,12,etc...
--replace=R replaces STRING with another string (max=16 chars).
Note: cat --locate=color red/green --replace=color white will result in color whitereen. The command cat --locate=c --replace=coloR --number=1 /menu.lst will change color to coloR
--number=N number of replacements to be made or locations to be listed

One use is to change the contents of a file (via byte replacement).

ls (0xff)/ && root (0xff)
ls (0xff)/I386/ && cat --locate=rdisk(1) --replace=rdisk(2) (0xff)/I386/TXTSETUP.SIF
ls (0xff)/AMD64/ && cat --locate=rdisk(1) --replace=rdisk(2) (0xff)/AMD64/TXTSETUP.SIF
ls (0xff)/ && chainloader (0xff)/I386/SETUPLDR.BIN
ls (0xff)/ || rootnoverify (hd0)
ls (0xff)/ || chainloader (hd0)+1

Note: cat --replace will only work if writes to the target device is allowed. Thus changing a menu.lst file under QEMU will not work as QEMU does not allow writes to a mounted physical device.
Tip: To prevent grub4dos listng hex positions use debug 0 in the menu.

Part 5 - Troubleshooting

grub4dos has very powerful and useful menu editing and command line features. To try this, let us boot from our USB pen and select the Memtest86 menu item - but don't press [Enter] - instead press 'e' for edit (note you must be in the grub4dos menu system, if in the GFXmenu system, press the [ESC] key to get to the grub4dos menu). The menu lines for the Memtest86 menu will be displayed when e is pressed. You can now edit these lines and add or delete lines and try to fix any problems. Any changes you make however will NOT permanently change the menu.lst file, the changes are only temporary. There is help text below the edit window to help you to edit the menu entries.

Often though, editing the menu does not help much as you need to see what is going on when each of the menu commands run and perhaps 'single-step' through them. Press 'c' for command line interpreter and you will be given a command prompt. You can now type in the commands one by one and observe what happens. Entering a partial command and hitting the [TAB] key will often complete the command or give a list of possible valid values to complete the command. Remember to reboot each time you try a new set of commands and try to boot (type 'boot' from the command line to try to boot). Some useful commands to help debug your menu items are:
help - to see a list of commands
help map - to see the syntax of map command
ls - list files and folders at the current root location
map --status - displays what devices are present and if they are 'hooked' by grub4dos
map ( [TAB] - will print all possible disks that it can see - e.g. Possible disks are : hd0 hd1 rd cd
root - displays the root device - e.g. (hd0,0): Filesystem type is fat, partition type 0x0c
find (hd0, [TAB] - shows all possible partitions on first hard disk
geometry - show current drive geometry
geometry --tune - alter current drive geometry reported by BIOS to match that of MBR
find +1 - list all devices with a known filesystem
find - list all devices
boot - boot using the device/file previously selected

Example debug commands and there results (click to enlarge)

for a full list of commands in the latest version included with RMPrepUSB - see here.

Tip: to aid debugging, it is good practice to use the following two lines at the beginning of each menu item to undo any previous drive mappings (though it can be quite slow)

map --unhook
map --unmap=0:0xff

If booting to DOS or linux, you may get better results (helps prevent flashing cursor syndrome!) using the geometry tune and sync commands to ensure the correct disk geometry - e.g.

title More reliable MS-DOS boot on any system
find --set-root /io.sys
geometry --tune
geometry --sync
chainloader /io.sys

Another tip is to turn on debugging using

#case sensitive!
debug on

You have a choice of debug on(2), off (0) or normal (1) or a number. Normal is the default. A value of -1 tends to turn off any normal extra messages such as timeout countdowns or information messages. The command debug status displays the current debug level number.

Another trick for better results is to use && and || (which means AND and OR) - here is an example -->

title here is a test
#turn off debug and prevent countdown timer from displaying
debug -1
ls /my.iso && clear && pause --wait=3 I found /my.iso!
#now turn debug on again
debug normal
(put more commands here)

This says 'list /my.iso to the console - if it was there then clear the screen - if that worked output the message 'I found /my.iso' and wait for 3 seconds or until a key is pressed'.

The command pause --test-key will output the scancode of the next key that you press.

To have a menu entry which takes you to the command line shell, use 'commandline' in a menu entry - this may be useful for debugging:

title Goto grub4dos command line
(some command)
(some command)
(some command)
#now drop to command line and try a few things before typing boot to test booting...
find
ls /
commandline

Another useful menu entry which will reload your menu.lst file after you have just changed it (e.g. whilst running under an emulator and to save rebooting under the emulator) is:

title Reload menu.lst
configfile /menu.lst

errorcheck off will prevent grub4dos aborting if it finds an error with any command. This means you can try several commands in a row until one works:

errorcheck off
find --set-root --ignore-floppies --ignore-cd /boot/grub/menu.lst && configfile /boot/grub/menu.lst
find --set-root --ignore-floppies --ignore-cd /grub/menu.lst && configfile /grub/menu.lst

Single-Stepping
If grub4dos has trouble booting or finding your menu.lst, then as soon as it starts to boot, keep hitting the INSERT key. Grub4dos will then be in single-step mode and you can see error messages which are normally hidden. Hit a key to execute each next step until you see your menu:

Want to know if your USB drive is booting as a hard disk or floppy?

title who am I?
checkrange 0x80 read 0x8280 && pause --wait=3 I am Hard Disk 0
checkrange 0x81 read 0x8280 && pause --wait=3 I am Hard Disk 1
checkrange 0x82 read 0x8280 && pause --wait=3 I am Hard Disk 2
checkrange 0x00 read 0x8280 && pause --wait=3 I am Floppy Disk 0
checkrange 0x01 read 0x8280 && pause --wait=3 I am Floppy Disk 1
reboot

This works because the BIOS keeps the boot device number at 0x8280 (the value held there can be: 80 hex is hard disk 0, 81h is hard disk 1, 0 is floppy disk 0, etc.).
You can also use it like this to always boot from your hard disk, even if the USB drive booted as a floppy on one system and a hard disk on another:

checkrange 0x80 read 0x8280 && map (hd1) (hd0)
checkrange 0x80 read 0x8280 && map --hook
chainloader (hd0)+1

These menu items mean: if the USB booted as hd0 then map my real hard disk as hd0 - now boot from hd0.
So if the UFD booted as a floppy the system will boot from hard disk (hd0), if the USB drive booted as hd0, grub4dos will map hd1 (the hard drive) as hd0 and then boot from hd0 (the hard disk).

Or if you always want your USB drive to boot as a floppy disk on any system...

title Always boot from USB AS A FLOPPY
checkrange 0x80 read 0x8280 && map (hd0,0)+1 (fd0)
checkrange 0x80 read 0x8280 && map (hd1) (hd0)
checkrange 0x80 read 0x8280 && map --hook
chainloader (fd0)+1
rootnoverify (fd0)
map --floppies=1
map --harddrives=1
boot

WENV

Wenv (available on Beta downloads page) is a grub4dos utility (a program) that you can run under the grub4dos environment. It is just like an executable that you would run under DOS (e.g. find.exe) but it runs under grub4dos. It allows you to use environment variables in your menu.lst files or to run a script file which can execute grub4dos commands. For instance....

(Note: the line numbers in the menu below are not normally present in a grub4dos menu.lst - they have been added for reference purposes only):

  1. title Install Windows 7 64-bit Enterprise Edition\nRun the Windows install DVD to install a copy of Windows to your hard disk
  2. /Imdisk/wenv set iso=/iso/en_windows_7_enterprise_with_sp1_x64_dvd_620201.iso
  3. find --set-root/ImDisk/myiso.cmd
  4. dd if=()/ImDisk/au.xml of=()/AutoUnattend.xml
  5. dd if=()/ImDisk/cr.txt of=()/ImDisk/myiso.cmd
  6. /ImDisk/wenv call write ()/ImDIsk/myiso.cmd SET MYISO=${iso}\r\n
  7. /ImDisk/wenv call map ${iso} (0xff)
  8. map (hd0) (hd1)
  9. map (hd1) (hd0)
  10. map --hook
  11. chainloader (0xff)
Note that line 2 sets the grub4dos environment variable 'iso' to the path of the ISO file by running the wenv executable with parameters.
In line 6 and line 7 we can use this variable value by substituting it with ${iso}.
Note that wenv needs to have a full path as grub4dos needs to find the wenv file which is in the /ImDisk folder in this example.
Also note that to use environment variables and wenv with grub4dos commands, we need to 'call' the grub4dos command, this why lines 6 and 7 start with '/ImDisk/wenv call'

If you copy the grub4dos executable file wenv (available on Beta downloads page) to the USB drive /ImDisk folder, you can make the menu.lst easier to edit and add more ISO files.
The Wenv download zip file also includes an English translated text file which I have added for you to study.

WENV list of commands currently supported:

SET to set/change/add/delete/display variables
GET display variable/variables and get length of the variable in _GET internal variable
FOR similar to the windows shell FOR cmd instruction
CALC simple calculator (priority from left to right, does not support brackets)
ECHO Display a message or variable to the screen
READ a file and run the commands inside - similar to a .cmd batch file (must use WENV supported commands) also supports parameters.
CHECK check if an equation is true or false, if it returns true a command can be executed
RESET clear/reset a variable
CALL call the grub4dos shell to execute a grub4dos command

Note: SET, GET, FOR, RESET, CALC and ECHO are largely redundant now as similar functions are built into the latest grub4dos versions from chenall (included in RMPrepUSB).

For instance, if you type /wenv set in the grub4dos command console window, then wenv will display all current grub4dos environment variables.

Here is another example of how you can use wenv (note: this time wenv is located in the root of the drive and not in the ImDisk folder):

title Specify an iso file to run
# list all files in the /boot/imgs folder so the user can see them
ls /boot/imgs/
echo
# Ask user which iso they want (name is converted to uppercase as $U is specified)
/WENV set ask=$U,$input,Enter iso name with no extension (e.g. dban) :
/WENV get ask || echo No iso file specified! && configfile /menu.lst
clear
/WENV echo Loading /boot/imgs/${ask}.iso - please wait ...
# run the grub4dos map command and specify the iso file we want to load
/WENV call map --mem (bd)/boot/imgs/${ask}.iso (0xff)
map --hook
chainloader (0xff)

# Examples using the RUN.bat file (included with the download)
title Auto-make menu for /BOOT/IMGS/ folder
# call the RUN batch file and create a configfile in the ramdrive for all image files
/RUN.bat .Automenu
# Load the new configfile
configfile (md)0x3000+0x10

title Boot dos
# call the RUN batch file with the file we want to load in the /BOOT/IMGS folder specified
/RUN.bat DOS622.IMA
# Add the boot command so the user can use the cursor keys to select this menu entry
boot

For an example of how to make a script file which can run under grub4dos (which must begin with the text !BAT), see the file RUN.BAT example included with the wenv.zip download.

---- FIN -----

I hope this is enough to get you started. For more info on how to boot specific iso's visit Boot-Land's grub4dos forum here - for menu.lst entries for ISO booting see here. Also see Part 6 below for menu items I have personally tested.

If you have any hints or tips or have any successful grub4dos menu entries that you have 100% tested, please use the Contact Me tab and let me know and I will add them here.

As for fancy graphical menus... here is one I prepared earlier...

Was this Tutorial easy to follow?
Could it be improved?
Please click the Contact Me tab at the top of this page and let me know
so we can help others to find the 'Joys of Grub4dos'!

Part 6 - Tested menu.lst entry examples

gfxmenu /message
color black/cyan yellow/cyan
timeout 1
default 0
# line below will ensure the gfxmenu is always loaded even after an error
configfile /menu.lst

#This entry sends an ESC character which can be used to exit from the GFXMenu back to the grub4dos text menu (or the user can just press ESC instead)
#The file esc.txt must exist and contain the ESC character (0x1b or 27 or 033 octal) - the esc.txt file is in Beta Downloads section if you want it!
title grub4dos menu
cat /esc.txt && clear

title Reboot
reboot

title Switch Off
halt

#this assumes you have booted from a USB drive and you want to boot from the hard disk
title Boot from 1st Hard Disk \nBoot from MBR of first hard disk
map (hd0) (hd1)
map (hd1) (hd0)
map --hook
chainloader (hd0)+1
rootnoverify (hd0)

title FreeDOS
find --set-root /kernel.sys
chainloader /kernel.sys

title MSDOS
find --set-root /io.sys
chainloader /io.sys

title FreeDOS (AS HDD)
map (hd0) (hd1)
map (hd1) (hd0)
map --hook
rootnoverify (hd1,0)
chainloader /kernel.sys

title FreeDOS (AS FLOPPY)
map (hd0,0)+1 (fd0)
map (hd0) (hd1)
map (hd1) (hd0)
map --hook
chainloader (fd0)/kernel.sys
rootnoverify (fd0)
map --floppies=1

title MS-DOS (AS HDD)
rootnoverify (hd0,0)
chainloader (hd0,0)/io.sys

title Always boot from USB to MS-DOS AS FLOPPY DISK A:
checkrange 0x80 read 0x8280 && map (hd0,0)+1 (fd0)
checkrange 0x80 read 0x8280 && map (hd1) (hd0)
checkrange 0x80 read 0x8280 && map --hook
ls (fd0)/io.sys && clear && pause --wait=1 /IO.SYS found on floppy disk
ls (fd0)/io.sys || pause --wait=3 /IO.SYS not found on floppy disk
ls (fd0)/io.sys && chainloader (fd0)/io.sys
ls (fd0)/io.sys && rootnoverify (fd0)
ls (fd0)/io.sys && map --floppies=1
ls (fd0)/io.sys && map --harddrives=1
clear
boot

title MS-DOS (AS FLOPPY) AND HDD as HDD0
map (hd0,0)+1 (fd0)
# map the first partition of the hard disk as a floppy disk
map (hd0) (hd32)
# map the UFD as a virtual cd
map (hd1) (hd0)
# map the real hard disk as hard disk 0
map --hook
# hook Int13 interrupts so all map changes take affect
chainloader (fd0)/io.sys
# load the io.sys code into memory from the floppy disk (now ufd is fd0)
rootnoverify (fd0)
# set the file root as the floppy disk
map --floppies=1
map --harddrives=1
# Tweak BIOS device numbers so DOS sees 1 floppy and 1 hd

title MS-DOS (AS FLOPPY) AND HDD as HDD0 (no comments)
map (hd0,0)+1 (fd0)
map (hd0) (hd32)
map (hd1) (hd0)
map --hook
chainloader (fd0)/io.sys
rootnoverify (fd0)
map --floppies=1
map --harddrives=1

title WinPe v2
map /bootmgr (rd)
chainloader (rd)+1
root ()

;Note:  make sure the 'cheat code'  fromusb is present and also the bootfromiso path to the iso file on the USB drive starts with a forward slash /
;The ISO filename needs to be 8.3 and is case sensitive too!
title PCLinuxOS LiveCD \n * Boot direct from ISO file
map --unhook
map --unmap=0:0xff
find --set-root --ignore-floppies /pclos.iso
map --heads=0 --sectors-per-track=0 /pclos.iso (0xff)
map --hook
root (0xff)
kernel (0xff)/isolinux/vmlinuz fromusb bootfromiso=/pclos.iso livecd=livecd root=/dev/rd/3 acpi=on vga=788 keyb=en vmalloc=256M edd=off
initrd (0xff)/isolinux/initrd.gz

title BackTrack 4 Final LiveCD (extracted ISO contents to bt4 folder)
find --set-root /bt4/boot/vmlinuz
kernel /bt4/boot/vmlinuz BOOT=/bt4/casper boot=/bt4/casper nopersistent rw quiet vga=0x315
initrd /bt4/boot/initrd.gz

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

#This method of running memtest86+ works on more PCs than the previous one
title memtest.img (memtest.img obtained from ISO)
find --set-root /memtest.img
map /memtest.img (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)
map --floppies=1

title memtest86+ (bin file)
find --set-root /memtest.bin
kernel /memtest.bin

# USB Boot -> Fat32 Formatted
title Norton Ghost 15 (hd32)
find --set-root /iso/Ghost15.iso
map /iso/Ghost15.iso (hd32)
map --hook
root (hd32)
chainloader /BOOTMGR

title Ultimate Boot CD (UBCD) v5.0 final\nthis is the latest 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.
find --set-root /ubcd50.iso
map /ubcd50.iso (hd32)
map --hook
root (hd32)
chainloader (hd32)

# only about 2MB is saved by using 7zip to compress the iso to a .gz file
title Hirens Boot CD 13.1 using firadisk \nBoot to Hirens Boot CD in RAM
find --set-root --ignore-floppies --ignore-cd /HirensBCD.13.1.iso.gz
map --mem /firadisk.gz (fd0)
map --mem /HirensBCD.13.1.iso.gz (0xff)
map --hook
root (0xff)
chainloader (0xff)

# ---- GPARTED ---

title 1 GParted Live (0.8.1-3)
find --set-root --ignore-floppies /live/vmlinuz
kernel /live/vmlinuz boot=live config noswap noprompt ip=frommedia nosplash
initrd /live/initrd.img

title 2 GParted Live (0.8.1-3) ToRAM
find g: 0px;">
# run the grub4dos map command and specify the iso file we want to load
/WENV call map --mem (bd)/boot/imgs/${ask}.iso (0xff)
map --hook
chainloader (0xff)

# Examples using the RUN.bat file (included with the download)
title Auto-make menu for /BOOT/IMGS/ folder
# call the RUN batch file and create a configfile in the ramdrive for all image files
/RUN.bat .Automenu
# Load the new configfile
configfile (md)0x3000+0x10

title Boot dos
# call the RUN batch file with the file we want to load in the /BOOT/IMGS folder specified
/RUN.bat DOS622.IMA
# Add the boot command so the user can use the cursor keys to select this menu entry
boot

For an example of how to make a script file which can run under grub4dos (which must begin with the text !BAT), see the file RUN.BAT example included with the wenv.zip download.

---- FIN -----

I hope this is enough to get you started. For more info on how to boot specific iso's visit Boot-Land's grub4dos forum here - for menu.lst entries for ISO booting see here. Also see Part 6 below for menu items I have personally tested.

If you have any hints or tips or have any successful grub4dos menu entries that you have 100% tested, please use the Contact Me tab and let me know and I will add them here.

As for fancy graphical menus... here is one I prepared earlier...

Was this Tutorial easy to follow?
Could it be improved?
Please click the Contact Me tab at the top of this page and let me know
so we can help others to find the 'Joys of Grub4dos'!

Part 6 - Tested menu.lst entry examples

gfxmenu /message
color black/cyan yellow/cyan
timeout 1
default 0
# line below will ensure the gfxmenu is always loaded even after an error
configfile /menu.lst

#This entry sends an ESC character which can be used to exit from the GFXMenu back to the grub4dos text menu (or the user can just press ESC instead)
#The file esc.txt must exist and contain the ESC character (0x1b or 27 or 033 octal) - the esc.txt file is in Beta Downloads section if you want it!
title grub4dos menu
cat /esc.txt && clear

title Reboot
reboot

title Switch Off
halt

#this assumes you have booted from a USB drive and you want to boot from the hard disk
title Boot from 1st Hard Disk \nBoot from MBR of first hard disk
map (hd0) (hd1)
map (hd1) (hd0)
map --hook
chainloader (hd0)+1
rootnoverify (hd0)

title FreeDOS
find --set-root /kernel.sys
chainloader /kernel.sys

title MSDOS
find --set-root /io.sys
chainloader /io.sys

title FreeDOS (AS HDD)
map (hd0) (hd1)
map (hd1) (hd0)
map --hook
rootnoverify (hd1,0)
chainloader /kernel.sys

title FreeDOS (AS FLOPPY)
map (hd0,0)+1 (fd0)
map (hd0) (hd1)
map (hd1) (hd0)
map --hook
chainloader (fd0)/kernel.sys
rootnoverify (fd0)
map --floppies=1

title MS-DOS (AS HDD)
rootnoverify (hd0,0)
chainloader (hd0,0)/io.sys

title Always boot from USB to MS-DOS AS FLOPPY DISK A:
checkrange 0x80 read 0x8280 && map (hd0,0)+1 (fd0)
checkrange 0x80 read 0x8280 && map (hd1) (hd0)
checkrange 0x80 read 0x8280 && map --hook
ls (fd0)/io.sys && clear && pause --wait=1 /IO.SYS found on floppy disk
ls (fd0)/io.sys || pause --wait=3 /IO.SYS not found on floppy disk
ls (fd0)/io.sys && chainloader (fd0)/io.sys
ls (fd0)/io.sys && rootnoverify (fd0)
ls (fd0)/io.sys && map --floppies=1
ls (fd0)/io.sys && map --harddrives=1
clear
boot

title MS-DOS (AS FLOPPY) AND HDD as HDD0
map (hd0,0)+1 (fd0)
# map the first partition of the hard disk as a floppy disk
map (hd0) (hd32)
# map the UFD as a virtual cd
map (hd1) (hd0)
# map the real hard disk as hard disk 0
map --hook
# hook Int13 interrupts so all map changes take affect
chainloader (fd0)/io.sys
# load the io.sys code into memory from the floppy disk (now ufd is fd0)
rootnoverify (fd0)
# set the file root as the floppy disk
map --floppies=1
map --harddrives=1
# Tweak BIOS device numbers so DOS sees 1 floppy and 1 hd

title MS-DOS (AS FLOPPY) AND HDD as HDD0 (no comments)
map (hd0,0)+1 (fd0)
map (hd0) (hd32)
map (hd1) (hd0)
map --hook
chainloader (fd0)/io.sys
rootnoverify (fd0)
map --floppies=1
map --harddrives=1

title WinPe v2
map /bootmgr (rd)
chainloader (rd)+1
root ()

;Note:  make sure the 'cheat code'  fromusb is present and also the bootfromiso path to the iso file on the USB drive starts with a forward slash /
;The ISO filename needs to be 8.3 and is case sensitive too!
title PCLinuxOS LiveCD \n * Boot direct from ISO file
map --unhook
map --unmap=0:0xff
find --set-root --ignore-floppies /pclos.iso
map --heads=0 --sectors-per-track=0 /pclos.iso (0xff)
map --hook
root (0xff)
kernel (0xff)/isolinux/vmlinuz fromusb bootfromiso=/pclos.iso livecd=livecd root=/dev/rd/3 acpi=on vga=788 keyb=en vmalloc=256M edd=off
initrd (0xff)/isolinux/initrd.gz

title BackTrack 4 Final LiveCD (extracted ISO contents to bt4 folder)
find --set-root /bt4/boot/vmlinuz
kernel /bt4/boot/vmlinuz BOOT=/bt4/casper boot=/bt4/casper nopersistent rw quiet vga=0x315
initrd /bt4/boot/initrd.gz

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

#This method of running memtest86+ works on more PCs than the previous one
title memtest.img (memtest.img obtained from ISO)
find --set-root /memtest.img
map /memtest.img (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)
map --floppies=1

title memtest86+ (bin file)
find --set-root /memtest.bin
kernel /memtest.bin

# USB Boot -> Fat32 Formatted
title Norton Ghost 15 (hd32)
find --set-root /iso/Ghost15.iso
map /iso/Ghost15.iso (hd32)
map --hook
root (hd32)
chainloader /BOOTMGR

title Ultimate Boot CD (UBCD) v5.0 final\nthis is the latest 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.
find --set-root /ubcd50.iso
map /ubcd50.iso (hd32)
map --hook
root (hd32)
chainloader (hd32)

# only about 2MB is saved by using 7zip to compress the iso to a .gz file
title Hirens Boot CD 13.1 using firadisk \nBoot to Hirens Boot CD in RAM
find --set-root --ignore-floppies --ignore-cd /HirensBCD.13.1.iso.gz
map --mem /firadisk.gz (fd0)
map --mem /HirensBCD.13.1.iso.gz (0xff)
map --hook
root (0xff)
chainloader (0xff)

# ---- GPARTED ---

title 1 GParted Live (0.8.1-3)
find --set-root --ignore-floppies /live/vmlinuz
kernel /live/vmlinuz boot=live config noswap noprompt ip=frommedia nosplash
initrd /live/initrd.img

title 2 GParted Live (0.8.1-3) ToRAM
find --set-root --ignore-floppies /live/vmlinuz
kernel /live/vmlinuz boot=live config noswap noprompt toram=filesystem.squashfs ip=frommedia nosplash
initrd /live/initrd.img

title 3 GParted Live (0.8.1-3) without framebuffer
find --set-root --ignore-floppies /live/vmlinuz
kernel /live/vmlinuz boot=live config noswap noprompt ip=frommedia nomodeset vga=normal nosplash
initrd /live/initrd.img

title 4 GParted Live (0.8.1-3) failsafe
find --set-root --ignore-floppies /live/vmlinuz
kernel /live/vmlinuz boot=live config noswap noprompt acpi=off irqpoll noapic noapm nodma nomce nolapic nosmp ip=frommedia nomodeset vga=normal nosplash
initrd /live/initrd.img

#Note: if using FAT filesystem, the findiso pathname is CaSeSeNsItIvE!
title 5 GParted Live (0.8.1-3) ISO ToRAM
find --set-root --ignore-floppies /iso/gparted-live-0.8.1-3.iso
map --heads=0 --sectors-per-track=0 /iso/gparted-live-0.8.1-3.iso (0xff) || map --mem --heads=0 --sectors-per-track=0 /iso/gparted-live-0.8.1-3.iso (0xff)
map --hook
root (0xff)
kernel /live/vmlinuz boot=live config
      union=aufs       noswap noprompt vga=788 ip=frommedia
      findiso=/iso/gparted-live-0.8.1-3.iso
      toram=filesystem.squashfs
initrd /live/initrd.img

# -----

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

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

# boot from the .iso file (160MB) or use 7Zip to compress it to a .gz file (68MB)
title BartPE ISO using firadisk \nBoot to BartPE in RAM
find --set-root --ignore-floppies --ignore-cd /Bartpe.iso
map --mem /firadisk.gz (fd0)
map --mem /Bartpe.iso (0xff)
map --hook
root (0xff)
chainloader (0xff)

title DSLinux ISO
find --set-root /dsl4410.iso
map /dsl4410.iso (hd32)
map --hook
root (hd32)
chainloader (hd32)

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

title KNOPPIX 6.2.1\nNote: Must use modified initrd.gz to boot from ISO - Note: version specific - does not work with 6.7.0!
#http://knol.google.com/k/yoshihide-nomura/how-to-boot-knoppix-directly-from-iso/2vzr3sm0dzndc/1#
#http://www.knoppix.net/wiki/Cheat_Codes
#http://archive.yoshimov.com/knoppix/initrd-mod-6.2.1.gz has modified initrd file
#iso file and modifed initrd placed in ISO folder in this example
find --set-root /iso/KNOPPIX_V6.2.1CD-2010-01-31-EN.iso
map /iso/KNOPPIX_V6.2.1CD-2010-01-31-EN.iso (hd32) || map --mem /iso/KNOPPIX_V6.2.1CD-2010-01-31-EN.iso (hd32)
map --hook
root (hd32)
echo "Loading kernel.."
kernel /boot/isolinux/linux ramdisk_size=100000 lang=en vt.default_utf8=0 apm=power-off vga=791 nomce noeject noprompt quiet loglevel=0 tz=localtime fromiso=iso/KNOPPIX_V6.2.1CD-2010-01-31-EN.iso edd=off --
echo "Loading modified initrd downloaded from http://archive.yoshimov.com/knoppix/initrd-mod-6.2.1.gz"
initrd (bd)/iso/initrd-mod-6.2.1.gz || initrd (hd0,0)/iso/initrd-6.2.1.gz

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

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

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

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

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

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

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

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

#name must be in pmagic-x.y.iso format or will not find sqfs file
title PC CMOS Cleaner and Parted Magic 5.7 ISO
find --set-root /pmagic-5.7.iso
map --heads=0 --sectors-per-track=0 /pmagic-5.7.iso (hd32)
map --hook
root (hd32)
chainloader (hd32)

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

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

#load a gzipped floppy disk image (convert to .gz using gzip or 7Zip)
title MSDOS 6.22 using chainloader from gz file
find --set-root /dos622.ima.gz
map --mem /dos622.ima.gz (fd0)
map --hook
rootnoverify (fd0)
chainloader (fd0)+1

title PLD RescueCD - Linux RCDx86_298.iso\n http://rescuecd.pld-linux.org/
find --set-root /RCDx86_298.iso
map /RCDx86_298.iso (hd32)
map --hook
root (hd32)
chainloader (hd32)

#MEMDISK is not really needed as the built in grub4dos CHAINLOADER command is similar in action and allows for direct drive remapping, However, it is useful in being able to load .zip files which chainloader cannot (chainloader can load .gz compressed files however).
#MEMDISK allows booting legacy operating systems. MEMDISK can boot floppy images, hard disk images and some ISO images see here for details.

#MEMDISK simulates a disk by claiming a chunk of high memory for the disk and a (very small - 2K typical) chunk of low (DOS) memory for the driver itself, then hooking the INT 13h (disk driver) and INT 15h (memory query) BIOS interrupts. The memdisk binary can be obtained from the syslinux project here .

#initrd loads the specified file into the ramdrive (initialise ramdrive)

title Memtest 86+

kernel /memdisk raw
initrd /memtest.img

title MEMTEST86+ iso using memdisk
kernel /memdisk iso
initrd /mt410.iso

#use raw mode (raw access to protected mode)
title MSDOS floppy disk image
kernel /memdisk raw
initrd /dos622.ima
kernel /live/vmlinuz boot=live config noswap noprompt toram=filesystem.squashfs ip=frommedia nosplash
initrd /live/initrd.img

title 3 GParted Live (0.8.1-3) without framebuffer
find --set-root --ignore-floppies /live/vmlinuz
kernel /live/vmlinuz boot=live config noswap noprompt ip=frommedia nomodeset vga=normal nosplash
initrd /live/initrd.img

title 4 GParted Live (0.8.1-3) failsafe
find --set-root --ignore-floppies /live/vmlinuz
kernel /live/vmlinuz boot=live config noswap noprompt acpi=off irqpoll noapic noapm nodma nomce nolapic nosmp ip=frommedia nomodeset vga=normal nosplash
initrd /live/initrd.img

#Note: if using FAT filesystem, the findiso pathname is CaSeSeNsItIvE!
title 5 GParted Live (0.8.1-3) ISO ToRAM
find --set-root --ignore-floppies /iso/gparted-live-0.8.1-3.iso
map --heads=0 --sectors-per-track=0 /iso/gparted-live-0.8.1-3.iso (0xff) || map --mem --heads=0 --sectors-per-track=0 /iso/gparted-live-0.8.1-3.iso (0xff)
map --hook
root (0xff)
kernel /live/vmlinuz boot=live config
      union=aufs       noswap noprompt vga=788 ip=frommedia
      findiso=/iso/gparted-live-0.8.1-3.iso
      toram=filesystem.squashfs
initrd /live/initrd.img

# -----

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

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

# boot from the .iso file (160MB) or use 7Zip to compress it to a .gz file (68MB)
title BartPE ISO using firadisk \nBoot to BartPE in RAM
find --set-root --ignore-floppies --ignore-cd /Bartpe.iso
map --mem /firadisk.gz (fd0)
map --mem /Bartpe.iso (0xff)
map --hook
root (0xff)
chainloader (0xff)

title DSLinux ISO
find --set-root /dsl4410.iso
map /dsl4410.iso (hd32)
map --hook
root (hd32)
chainloader (hd32)

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

title KNOPPIX 6.2.1\nNote: Must use modified initrd.gz to boot from ISO - Note: version specific - does not work with 6.7.0!
#http://knol.google.com/k/yoshihide-nomura/how-to-boot-knoppix-directly-from-iso/2vzr3sm0dzndc/1#
#http://www.knoppix.net/wiki/Cheat_Codes
#http://archive.yoshimov.com/knoppix/initrd-mod-6.2.1.gz has modified initrd file
#iso file and modifed initrd placed in ISO folder in this example
find --set-root /iso/KNOPPIX_V6.2.1CD-2010-01-31-EN.iso
map /iso/KNOPPIX_V6.2.1CD-2010-01-31-EN.iso (hd32) || map --mem /iso/KNOPPIX_V6.2.1CD-2010-01-31-EN.iso (hd32)
map --hook
root (hd32)
echo "Loading kernel.."
kernel /boot/isolinux/linux ramdisk_size=100000 lang=en vt.default_utf8=0 apm=power-off vga=791 nomce noeject noprompt quiet loglevel=0 tz=localtime fromiso=iso/KNOPPIX_V6.2.1CD-2010-01-31-EN.iso edd=off --
echo "Loading modified initrd downloaded from http://archive.yoshimov.com/knoppix/initrd-mod-6.2.1.gz"
initrd (bd)/iso/initrd-mod-6.2.1.gz || initrd (hd0,0)/iso/initrd-6.2.1.gz

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

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

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

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

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

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

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

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

#name must be in pmagic-x.y.iso format or will not find sqfs file
title PC CMOS Cleaner and Parted Magic 5.7 ISO
find --set-root /pmagic-5.7.iso
map --heads=0 --sectors-per-track=0 /pmagic-5.7.iso (hd32)
map --hook
root (hd32)
chainloader (hd32)

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

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

#load a gzipped floppy disk image (convert to .gz using gzip or 7Zip)
title MSDOS 6.22 using chainloader from gz file
find --set-root /dos622.ima.gz
map --mem /dos622.ima.gz (fd0)
map --hook
rootnoverify (fd0)
chainloader (fd0)+1

title PLD RescueCD - Linux RCDx86_298.iso\n http://rescuecd.pld-linux.org/
find --set-root /RCDx86_298.iso
map /RCDx86_298.iso (hd32)
map --hook
root (hd32)
chainloader (hd32)

#MEMDISK is not really needed as the built in grub4dos CHAINLOADER command is similar in action and allows for direct drive remapping, However, it is useful in being able to load .zip files which chainloader cannot (chainloader can load .gz compressed files however).
#MEMDISK allows booting legacy operating systems. MEMDISK can boot floppy images, hard disk images and some ISO images see here for details.

#MEMDISK simulates a disk by claiming a chunk of high memory for the disk and a (very small - 2K typical) chunk of low (DOS) memory for the driver itself, then hooking the INT 13h (disk driver) and INT 15h (memory query) BIOS interrupts. The memdisk binary can be obtained from the syslinux project here .

#initrd loads the specified file into the ramdrive (initialise ramdrive)

title Memtest 86+

kernel /memdisk raw
initrd /memtest.img

title MEMTEST86+ iso using memdisk
kernel /memdisk iso
initrd /mt410.iso

#use raw mode (raw access to protected mode)
title MSDOS floppy disk image
kernel /memdisk raw
initrd /dos622.ima

title MSDOS 6.22 using memdisk raw from zip file of floppy disk image (1.44MB image compressed as .zip file)
kernel /memdisk raw
initrd /dos622.zip

title MSDOS 6.22 using memdisk raw from .gz file of floppy disk image (1.44MB image compressed as .gz file)
kernel /memdisk raw
initrd /dos622.ima.gz

# Lock a menu entry to a MAC address (so that this will only work on one system which has MAC address = 00:23:54:58:32:6b!)
# Use SCANBIOH.exe DOS tool from Beta Downloads page to find the correct memory location that contains your MAC address
# You can also use this technique to match against your mainboard serial number or model type
# See http://reboot.pro/14640/page__view__findpost__p__130251 for details.

title Run MSSS only on my EeePC!
#prevent checkrange from printing contents on the screen so it looks neater!
debug off
#check for the MAC address in BIOS RAM area
checkrange 0x58542300 read 0xf0757 && checkrange 0x6b32 calc *0xf075b & 0xffff && echo OK - MAC ADDRESS 00:23:54:58:32:6b FOUND
#if not correct MAC address then reload menu
checkrange 0x58542300 read 0xf0757 || pause --wait=3 INCORRECT MAC ADDRESS! && configfile /menu.lst
checkrange 0x6b32 calc *0xf075b & 0xffff || pause --wait=3 INCORRECT MAC ADDRESS! && configfile /menu.lst
#now do any commands as normal
find --set-root /MSSS_Media32.iso
map /MSSS_Media32.iso (0xff) || map /MSSS_Media32.iso (0xff)
map --hook
chainloader (0xff)

#Note: if you want to check a byte at any memory location use:
checkrange 0x32 calc *0xf075b & 0xff || pause --wait=3 INCORRECT MAC ADDRESS! && configfile /menu.lst
#Note: if you want to check a word at any memory location use:
checkrange 0x6b32 calc *0xf075b & 0xffff || pause --wait=3 INCORRECT MAC ADDRESS! && configfile /menu.lst
#Note: if you want to check a 3 bytes at any memory location use:
checkrange 0x066b32 calc *0xf075b & 0xffffff || pause --wait=3 INCORRECT MAC ADDRESS! && configfile /menu.lst
#Note: if you want to check a DWORD (4 bytes) at any memory location use:
checkrange 0x05066b32 read 0xf075b || pause --wait=3 INCORRECT MAC ADDRESS! && configfile /menu.lst
or
checkrange 0x05066b32 calc *0xf075b & 0xFFFFffff || pause --wait=3 INCORRECT MAC ADDRESS! && configfile /menu.lst

checkrange can also be used to check a range of values - e.g. checkrange 0x00:0x10   or  checkrange 0x00,0x02,0x04

Click here to see the 'God-on-a-stick' menu.lst and folder contents for lots more examples.

keywords: grub, grub4dos, grubfordos, menu, introduction, howto, how to, gfx menu, gfxmenu, manual, getting started, teach, learn, menu, new version, latest, documentation, specs, how to, faq

Войти Условия использования Сообщить о нарушении Распечатать страницу Технология: Сайты Google

Search this site
Search web