The following was translated by Google
Translate from Chinese to English http://bbs.wuyou.net/forum.php?mod=viewthread&tid=322662&extra=page%3D1&page=1
WARNING: some formatting errors may be present.
Contents
- 1 Part 1 - ls, find, root, rootnoverify, map, cdrom, cat, cmp, dd, write, read, calc, checktime, echo, pager, clear
- 2 Part 2 - graphicsmode, vbeprobe, testvbe, setvbe, terminal, terminfo, font, background, foreground
- 3 Part 3 - halt, reboot, hide, unhide, hiddenflag, makeactive, partnew, parttype, blocklist, uuid, fstest
- 4 Part 4 - kernel, initrd, module, modulenounzip, chainloader, boot, pxe, quit
- 5 Part 5 - configfile, default, savedefault, timeout, title, iftitle, hiddenmenu, password, lock, md5crypt, commandline, gfxmenu, splashimage, color, outline
- 6 Part 6 - call, exit, shift, goto, set, setlocal, endlocal, if, checkrange, errorcheck, errnum, fallback, pause, command, insmod, delmod
- 7 Part 7 - help, debug, displaymem, geometry, is64bit, serial, tpm, setkey
- 8 New 0.4.6a 2018-08 commands (setmenu, beep)
-
9 Part 8 - Batch files and notes
- 9.1 Using Braces (grub4dos 2018-05 and later)
Part 1 - ls, find, root, rootnoverify, map, cdrom, cat, cmp, dd, write, read, calc, checktime, echo, pager, clear
ls
Similar to the Linux ls command, similar to the dir
command under Dos, list files and directories in the current directory (working
directory) under
ls /boot
Lists the current directory (working directory) under
names beginning with boot files and directories, do not use ls boot, it is only
valid in the root directory.
ls /boot /
Lists the current directory boot directory of files and
directories, do not use ls boot /, it is only valid in the root directory.
ls (hd0,0) /
Lists (hd0,0) files and directories, do not use ls
(hd0,0), it is only valid in (hd0,0) for the current disk.
ls dev
Drive a list of all lists (not including drive partition)
ls /boot /> nul && echo exist
Determine the directory /boot /exists, if it exists, then
the output exist (this method is invalid for an empty directory)
ls /boot> nul && echo exist! echo not exist
Determine whether there is a file name of the current
directory (working directory) to boot the beginning of the file or directory,
if it exists, then the output exist, otherwise the output not exist
ls (hd0,0) /boot /> nul && echo exist! echo
not exist
Judgment directory (hd0,0) /boot /exists, if it exists,
then the output exist, otherwise the output not exist
[Note: If no file folder, for the ls command is concerned
that the folder does not exist. ]
[Note: Due to the illusion of the file name of the
directory, the directory is called with the /generated by (ud) does not exist,
so ls (ud) /time, lists (ud) all the files, but ls (ud) /boot /they can list
all files in /boot /under, because the file names of these files are in /boot /beginning]
==============================
debug on
find
List all disks (disks, including partitions) (debug off = silent mode)
debug on
find +1
Lists all known file system disk (debug off = silent mode)
debug on
find checkrange 0x07 parttype
Lists all partitions of partition type 0x07 (NTFS) (debug off = silent mode)
find /ntldr checkrange 0x07 parttype
Find the partition type is 0x07 (NTFS) partitions which have /ntldr
file and list partitions found.
find --set-root /ntldr
Finds equipment /ntldr file, the device is set to first
found device, the current device is searched first.
find --set-root --ignore-floppies --ignore-cd /ntldr
Finds equipment /ntldr file, the device is set to first
find the current device. Ignore the floppy and CD-ROM.
find --set-root --devices=upnhcf /ntldr
Finds equipment /ntldr file, the device is set to first
find the current device. Specify search order: ud, pxe, network equipment, hard
disk, CD-ROM, floppy disk. The current root is always searched first.
find --set-root --devices=upnh /ntldr
Finds equipment /ntldr file, the device is set to first
find the current device. Specifies the search order, and ignore the floppy and
CD-ROM.
find --set-root ls /grub/
Finds /grub/ directory of the device, the device is set
to first find the current device. /grub /directory can not be empty, otherwise
it will ignore the directory.
debug on
find --set-root makeactive --status
Find first active primary partition, current device is searched first. (debug off = silent mode)
find --set-root=/boot/grub /boot/grub/menu.lst
Find device contains /boot/grub/menu.lst, current device searched first, and set the working
directory to /boot /grub
find root
Finds all formatted partitions and lists them... (requires 2016 or later version)
(hd0,0) Filesystem type is ntfs, partition type 0x07
(hd0,0)
(hd0,1) Filesystem type is ntfs, partition type 0x07
(hd0,1)
========
root
Displays the current device name and related information.
root (hd0,0)
The (hd0,0) as the current disk, the working directory is
/, effects and root = (hd0,0)/ .
root (hd-1,0)
The (hd-1,0) is first ptn of last hard disk, set as the current disk, root working directory
is /
root (hd0,0)/boot
The (hd0,0) as the current disk, the working directory is
/BOOT, effects and root = (hd0,0)/boot/ .
root ()/boot
Modify the working directory is /BOOT directory under the
current disk, effects and root = ()/boot.
root (hd0,0) > nul && echo ok ! echo fail
root (hd0,0) > nul || echo fail ! echo ok
The (hd0,0) is set to the current device, if successful, output ok, if unsuccessful, output fail. (The above two commands have the
same effect)
==============================
rootnoverify (hd0,0)
Equivalent to root (hd0,0), but does not test the contents of the partition. This is used in some systems installed outside the GRUB can
access the disk area, but still need to set the right circumstances the root
partition. Some parameters need to be installed in order to determine the
partition may be a problem.
The following commands can be executed correctly, but
would not replace the root:
rootnoverify (hd0)
chainloader +1
boot
==============================
Device Types:
(fd0) first floppy disk = (0x00)
(fd1) second floppy = (0x01)
(hd0) first hard = (0x80)
(hd1) second hard drive = (0x81) [0xA0 - 0XFF are CD devices, so max is hd31]
(hd-1) last hard disk
Use (hd) to create a new
virtual hard disk after the last hard disk
(cd0) first drive, equivalent to (hd32), --init created
by cdrom
(cd1) a second optical drive, which is equivalent to (hd33),
--init created by cdrom
Due to the ability to identify cdrom is too low, while
optical devices on the market almost all been replaced by U disk, so (cd?) This
format may be phased out.
(hd0,0) on a hard disk of the first primary partition
(hd0,4) on a hard disk first extended partition
(hd-1,0) and finally the first primary partition a hard
drive, or (hd-2,0) in this format, (hd-1, -1) not allowed in this format.
(hd #, 0) of the first primary partition (hard disk on #)
(hd #, 1) second primary partition (hard disk on #)
(hd #, 2) third primary partition (# on the hard disk)
(hd #, 3) fourth primary partition (hard disk on #)
(hd #, 4) first logical partition (# on the hard disk)
(hd #, 5) a second logical partition (on the hard disk #)
(hd #, 6) a third logical partition (on the hard disk #)
(hd #, 7) The fourth logical partitions (on hard disk #)
(hd32) first optical drive = (0xA0)
(hd33) second optical drive
(0xFF) final drive (hd127)
() The current disk
(bd) the initial boot device (devices including disk and
drive)
(cd) from the CD to start, Grub4Dos captured bootable CD,
if not booted from the CD, there is no (cd) device
(ud) Fbinst way to start making a hidden partition
(pd) PXE network boot device
(nd) network drives, now is not commonly used (nd no
longer exists and has been replaced by pd)
(md) memory drive, to achieve the whole memory as a disk
drive to visit
(rd) random storage drives.
(md) device accesses memory
from physical address 0, has 512 byte 'sectors'
(rd) can be accessed starting at any base memory
address
Named in digital equipment:
fd0 - fd126: 0x0 - 0x7E (virtual floppy diskettes and
exclude 0x21 and 0x23)
pxe: 0x21 (network boot device)
ud: 0x23 (Fbinst hidden partition)
rd: 0x7F (random memory storage drive)
hd0 - hd30: 0x80 - 0x9E (hard disk and virtual hard
disks)
cd: 0x9F (captured bootable CD, this is not necessarily
correct, depending on the bios may be)
hd32 - hd127: 0xA0 - 0xFF (CD and virtual CD-ROM)
+1 Indicates the rest of the device following the first
sector of a device as a single file view:
(hd0)+1 will be the first sector of the entire hard disk
as a file (of a sector)
(hd0,0)+1 will be the first sector of the partition as a
whole file (of a sector)
(fd0)+1 will be the first sector of a floppy disk as a
whole file (of a sector)
(cd0)+1 will be the first sector of the entire disc as a
file (of a sector - sectors usually 2048 bytes)
(md)+1 will be the first sector of the entire memory as
a file (of a sector)
(rd)+1 this rather special, all the contents of the
specified memory as a file
[Note: (rd)+1 This always represent the file, which
contains all the bytes are stored in the (rd) ]
Can also use + 2, + 3, etc., represents the first two
or first three sectors viewed as a single file:
(hd0)+2 first two sectors entire hard disk as a file (of
two sectors)
(hd0,0)+3 first three sectors throughout the district as
a file (a total of three sectors)
(fd0)+5 entire first 5 sectors of the floppy disk as a
file (a total of five sectors)
(cd0)+10 first 10 sectors of the entire disc as a file
(of 10 sectors)
(md)+32 32 sectors across the front of memory as a file
(a total of 32 sectors)
(rd)+2 first two sectors of the specified memory as a file
(of two sectors)
You can also use a similar approach 32+5:
(hd0)512+2 the first two sectors after 512 sectors of the
entire hard drive as a file (two sectors)
(hd0,0)1+3 The three sectors starting at the 2nd sector of the first partition as a file (a total of three sectors)
(fd0)1+1 will be sector #2 of whole
floppy disk as a file (one sector)
(cd0)128+1 will be sector 128 as a file (one sector)
(md)0+32 32 sectors the start of memory as a
file (a total of 32 sectors)
(rd)0+1 is equivalent to (rd) +1, all the contents of
the specified memory as a file
About the (rd) Device:
(rd) devices only references the memory region, the memory
area (rd) device is not being referenced protected, you can (rd) be interpreted
as pointing to a block of memory pointer. In Grub4Dos, many things are free,
unprotected, without limitation, (rd) is one of them.
(rd) is not a int13 device, but merely a grub4dos device.
In grub4dos inside presence (rd) device, but after entering the DOS, there is
no (rd) equipment was.
(rd)+1 always represents the entire contents (rd)
device, rather than the first sector.
You can get information (rd) device via the following
address:
set /a rdnum=*0x82CC # get the (rd) device number
set /a rdbase=*0x82D0 # get the starting address (rd) devices
set /a rdsize=*0x82D8 # get the total size (rd) devices
Information can be freely set (rd) device through the
following methods:
map --ram-drive=0xFF7F # set (rd) device number of (rd)
map --mem --rd-base=50000 # Set (rd)
devices starting address
map --mem --rd-size=30000 # Set
(rd) devices the total size
map (hd0,1)+1 (fd0) # map a partition as a floppy drive
The following command only modifies the information (rd)
devices:
map --mem /FILE (rd)
Here (rd) pointing a memory area which contains the content of /FILE file, but this memory is not protected, thus the memory at any time may be accessed by other code, and even modify Grub4Dos itself .
The following commands also modifies the information (rd)
devices, but (rd) memory area pointed to is protected, because it (fd0)
overlap, and (fd0) is protected:
map --mem /FILE (rd)
map --mem /FILE (fd0)
map --hook
If do not change the order of the first two lines or it won't work!
map --status
Display the status of disk emulation.
map /PE.ISO (0xFF)
map --hook
The /PE.ISO mapped to (hd127) simulation disk, /PE.ISO
must be continuously stored in the disk can not be fragmented.
map --mem /PE.ISO (0xFF)
map --hook
/PE.ISO First loaded into memory, and then mapped to
(hd127) simulation disk, /PE.ISO may have debris.
map --mem=-2880 /FLOPPY.IMG (fd0)
map --hook
/FLOPPY.IMG is first loaded into memory, and then mapped to
(fd0) floppy disk emulation, (fd0) will occupy at least 1440KB (2880*512) of memory.
map --mem --top /BigPE.ISO (0xFF)
map --hook
The /BigPE.ISO loaded into high memory, and then mapped to
(hd127) simulation disk to load the image into high memory can not use gzip
compression, but not both achieve.
In grub4dos, the memory is divided into at 3.25G high
memory and low memory ends 3.25G mirroring can not cross this point. If your
memory is less than 3.25G, you do not have the high-end memory available.
map --unmap=0xFF
map --rehook
Uninstall (hd127) disk emulation. You can not use --unmap=(0xFF)
method to uninstall, - unmap= must be followed by a number.
--rehook used to stop the simulation disk and frees up
memory, equivalent --unhook then --hook (so it seems, map --unhook command does
not seem to be used separately)
map --unmap=0,0x80,0xFF
map --rehook
Uninstall multiple simulations disks.
map --unmap=0:0xFF
map --rehook
Uninstall all disk emulation.
If you want to uninstall a device by device name using a different method, you can do:
map (hd127) (hd127)
map --rehook
map --read-only /FLOPPY.IMG (fd0)
map --hook
(fd0) can only read, cannot write, prevent /FLOPPY.IMG
file is corrupted.
Mapped to emulate disk files can all be modified, whether
it is IMG, ISO, VHD, etc., unless --read-only parameter.
map --fake-write /FLOPPY.IMG (fd0)
map --hook
(fd0) is false writing state, data can be written, but
not recording to the (fd0), preventing /FLOPPY.IMG file from corrupted.
map --in-situ (hd0,4)+1 (hd0)
used to map a logical partition as a primary partition by creating virtual MBR and PBR in memory which will be accessed by BIOS calls.
Can be used to boot DOS-based OSs (DOS,Win95/98/Me) and trick it into thinking it is booting from a Primary partition.
Unlike the partnew command, no change is made to the physical MBR or PBR.
map --unsafe-boot /FLOPPY.IMG (fd0)
map --hook
Allow
modification boot sector.
MBR is protected from writes unless --unsafe-boot is used - e.g. map --unsafe-boot (hd0,0)/image.vhd (hd1)
map --- disable-chs-mode /FLOPPY.IMG (fd0)
map --hook
Disable (fd0) of CHS access.
map --disable-lba-mode /FLOPPY.IMG (fd0)
map --hook
Disable (fd0) the LBA access.
map command can also be used to modify the information
(rd) random access memory, the above have said.
map --add-mbt=option to be used with --mem. If option=0 master boot track will not be added automatically.
map --top option to be used with --mem. Use --top --mem if the file is >2GB.
map --mem will try to allocate memory at highest available address.
map --mem-max=, map --mem-min options to be used before map --mem. Allow user to manually limit range of address that map --mem can use. function parses K,M,G,T suffix after number - e.g. map --mem-max=4G.
map --mem will allocate memory even if the command fails due to insufficient RAM.
Note: In the map on the command line, (hdm, n) +1 style
of writing is interpreted as representative of the (hdm, n) partitions, rather
than just the first sector of the partition.
Note: - after unhook disk emulation, unless you then do --unmap, mapped disks will again be automatically mapped on next --hook
==============================
Disk swapping on the map command:
# Intended to be mapped to the current device (hd0)
map () (hd0)
# Intend to (hd0) is mapped to the current device
map (hd0) ()
# Begin mapping now
map --rehook
==============================
cdrom --init
map --hook
Mount ATAPI interface drive (You can access the map
--hook)
cdrom --stop
map --rehook
Uninstall ATAPI drive interface
==============================
cat /menu.lst
The display /menu.lst
cat --hex /grldr
To display the contents in hexadecimal of /grldr
cat --skip=1024 /menu.lst
display /menu.lst contents, skip the first 1KB
cat --length=10 /menu.lst
display /menu.lst contents only the first 10 bytes
cat --locate="\ x20" /menu.lst
Find two consecutive spaces (escape character + non
escape character) in /menu.lst the (case-sensitive)
cat --locate=abc /menu.lst
Find abc string (non-escaped characters) in /menu.lst the
(case-sensitive)
cat --locatei=abc /menu.lst
Find /menu.lst the string abc (case insensitive)
cat --locate=abc --number=3 /menu.lst
Find abc string /menu.lst show only the results of the
previous three found
cat --locate=abc --replace=def /menu.lst
Find the abc string /menu.lst and replaced def
cat --locate=abc --replace=def --number=3 /menu.lst
Find /menu.lst the abc string and replaced def, just
replace the three former results found
cat --locate=abc --replace=def --locate-align=16
/menu.lst
Find the abc string /menu.lst and replaced def, replace
only 16 position aligned with results
By the following command to see the effect of
--locate-align=16:
echo -n > /menu.lst
cat --locate=\x0 --replace=1 /menu.lst
cat /menu.lst
cat --locate=1 --replace=0 --locate-align=16 /menu.lst
cat /menu.lst
cat --length=0 ()-1
Fixed usage, access to the current partition address
offset in bytes - e.g. %@retval% returns 0x7E00 (=63*512)
cat --length=0 () /menu.lst
Get /menu.lst file size (if file >4GB then returns max 4GB)
cat --length=0 ()/menu.lst > nul && echo
exist ! echo not exist
/menu.lst Determine whether there is a file, if it
exists, then the output exist, otherwise the output not exist
Escape character summary:
\nnn 1-3 octal character code representation (\377)
octal maximum value of \377, exceeding the 377 code will then be converted
modulo 377, for example, \400 represents \0
\xnn a 2-digit hexadecimal chracters (0-9 A-F) (\x00-\xFF) code indicates that
the maximum value of \xFF
\ Blank space character
\\ \ Character (backslash)
\" " Character (double quotes)
\' ' Character (single quotes)
\a alert (bell)
\b backspace
\f formfeed
\n newline
\r carriage return
\t horizontal tab
\v vertical tab
[Note: Performing cat --locate= or cat --locatei =, you
can get the position of the last occurrence using %?%]
For example:
cat --locate=b /File > nul
set /a Last=%?% >
nul
Explanation: cat --locate=a /File returns results like 29 35 48 99 but the variable ? is set to the position of the last byte found.
With skill you can use &; operator to achieve this on one line (this does not work if you use &&)
set Last=-1 && cat --locate=a /File &; set /a
Last =%?% > nul
sets a to a space character:
set "a= "
set multiple spaces before a string:
set "a= here are spaces"
cmp /menu.lst /m.lst
Compares two files are identical.
cmp --hex /menu.lst /m.lst
Compare two files are identical, and compare the results
displayed in hexadecimal format.
cmp /menu.lst /m.lst > nul && echo same ! echo different
Compare two files are the same, if the same, then the
output same, otherwise the output different.
==============================
dd command
dd if=()/menu.lst of=()/m.lst
Copy the contents of the /m.lst in /menu.lst
dd if=()/menu.lst of=() /m.lst bs=32 count=5
A block size of 32 (default 512), copy data from five blocks from /menu.lst into /m.lst
dd if=()/menu.lst of=()/m.lst bs=10 skip=5 seek=6
10 as block size, copy data from /menu.lst into /m.lst
in. When copying, skip the first five blocks /menu.lst, and start reading from
the first 6 blocks, a write, skip the first seven blocks /m.lst from the first
eight blocks to start writing.
dd if=()/menu.lst of=()/m.lst buf=0x2000000 buflen=0x2000000
Copy the contents of the /m.lst /menu.lst, and when
copying from 0x2000000 position memory (32M location) take 0x2000000 space (32M
space) as a cache for copying large files, increasing the cache size dd can
accelerate write speeds.
[Note: The source and target files must be present, the
path must begin with a device name, the excess length of the file will be
discarded, the target file can not be gz compressed files, source files can be
compressed gz files, compressed files before replication be extracted. dd for
the entire device can read and write operations: dd if=(fd0) of=(fd1), with
caution. ]
==============================
write and read
write /menu.lst abc
Abc written in three characters at the beginning
/menu.lst file, overwriting the original characters.
write /menu.lst "abc"
Write five characters "abc" at the beginning
/menu.lst files, overwrite the original characters.
write /menu.lst \"abc\"
Write five characters "abc" at the beginning
/menu.lst files, overwrite the original characters.
[Note: The string is written, in addition to the
beginning of the space, other spaces, or single or double quotation marks do
not need to escape, escape can be processed, the backslash must be escaped]
[Note: The target file must exist, some beyond
the length of the file will be discarded, the target file can not be gz
compressed files, source files can be compressed gz files, compressed files
before copying will be extracted. write commands to operate the equipment:
write (fd0) abc, caution. ]
write --bytes=2 0x8274 0x2001
If the object is not written to a file or device, but a
number, this number represents a memory address, the address of the memory data
write modified to specify the value of the data to be written must be an
integer, not a string. Practice with the following memory address:
write 0x50000 -1
read 0x50000
>> Address 0x50000: Value 0xffffffff
write 0x50000 0
read 0x50000
>> Address 0x50000: Value 0x0 (four bytes, 32-bits)
write --bytes=3 (md)0x300+1 \x00\x01\x02 where bytes n = 1-8
If target is FILE (not ADDR) then must specify byte string \x00\x01 etc.
read 0x60000
Reads a 32-bit value from the specified location in memory, and displayed in hexadecimal form.
read -8 0x6000 (64-bit read)
[also calc *0x60000]
'raw write' and 'raw read' can be used to prevent decompression of gz or lzma source
==============================
Grub4dos itself to conventional memory usage situation is
now as follows:
00000 ~ 0FFFF occupied grub4dos program code and stack.
10000 ~ 1FFFF grub4dos future for code and data
retention.
20000 ~ 2FFFF is grub4dos geometry kernel automatically
detect occupancy, as a buffer.
30000 ~ 37FFF occupied grub4dos kernel conventional disk
read and write buffers.
38000 ~ 4FFFF grub4dos reserved for future expansion.
50000 ~ 7FFFF reserved for users
100,000 to 110,000 by the dd command of the disk buffer
occupancy.
[Note: The above content on memory allocation is not
necessarily accurate, correct me hope developers]
==============================
calc 1 + 1
1 + 1 is calculated, you can do: + (plus), - (minus), *
(multiplication), /(division),% (I), << (left), >> (right) , & (and), | (or), ^ (XOR)
calc 0xFF
Display 0xFF decimal and hexadecimal results
calc *0x8280
Display integer value stored at the memory 0x8280
calc *0x50000=1
The integer value stored at the memory 0x50000 changed to
1
calc *0x50000=*0x8280
The integer value stored at the memory 0x50000 change to the
integer value stored at 0x8280
calc *0x50000=1<<4
The integer value stored at the memory 0x50000 modify the
results of the calculated (1<<4=16)
[Note: In the set /a var=value in, value can be
calculated using the above method: set /ab=*0x8280]
calc and set /a minus number can be treated as a negative, but
to add a space after the minus sign, for example, the following code:
set a=-32
set /a b=0-%a%
Above the set command can not calculate the value of
0--32, with the following wording can be calculated (add a space after the
minus sign):
set a=-32
set /a b=0- %a%
Above the set command can calculate the value of 0- -32,
the result is 32.
==============================
checktime syntax checktime minutes hour dayofmonth month dayofweek(0-6) 0=Monday, 6=Sunday
checktime
Displays the current date and time the week
checktime * 0-12 * * * && echo morning ! echo pm
Display different information according to different
time. (Checktime points during the week day month)
checktime * * * * 6,0 && echo weekend ! echo
Weekday
Display different information according to different
time. (Checktime points during the week day month)
checktime * * * * * /2 && echo Fortnight ! echo
single week
Display different information according to different
time. (Checktime points during the week day month)
checktime 0,1-59/15 * * * * && echo whole
quarter of an hour ! echo quarter non-integer
Display different information according to different
time. (Checktime points during the week day month)
==============================
echo \\ Hello
Output on the screen \\ Hello (end of the line will
automatically add line breaks)
echo -n \\ Hello
Output on the screen \\ Hello (end of the line does not
automatically add a newline)
echo -e \\ Hello
Output on the screen \ Hello (-e that handles the escape
character)
echo -h
Echo display color table support
echo $[0x1F]abc
Use color table 1F at foreground and background colors
display abc
echo $[0x1F]abc$[0xE4]def
Use color table 1F at foreground and background colors
display abc, then use the foreground and background colors of the color table
E4 def display
echo -P:0101 abc
Abc displayed in the first row and first column of the
screen (must be a space after -P:xxxx)
echo -n > /menu.lst
Empty the contents of the file /menu.lst
0.4.6a 2016+
echo -e /X00FC/x18
/Xhhhh displays unicode/UTF-8 characters (must load a font file).
==============================
pager on
Open full screen page display mode
[Hit Q to quit, any other key to continue]
pager off
Close full screen page display mode
pager
Toggle page display mode switch
pager status
Output current page display full screen mode
clear
Clear the screen (to clear the contents displayed on the
screen)
Part 2 - graphicsmode, vbeprobe, testvbe, setvbe, terminal,
terminfo, font, background, foreground
graphicsmode
The current mode of display graphics
graphicsmode 0x12
Use vga mode (640 × 480), recommended vbe mode
graphicsmode 0x6A
Use vga mode (800x600, camera support is not very good
for some, there may be crashes), recommended vbe mode
graphicsmode -1 640
Use vbe mode, specify the resolution width of 640, if the
width of the monitor does not support this resolution will fail
graphicsmode -1 800 600
Use vbe mode, specify the resolution width of 800 and a
height of 600, if the monitor does not support this resolution will fail
graphicsmode -1 1024 768 32
Use vbe mode, specify the resolution width 1024, height
768, 32-bit color, if the monitor does not support this resolution or bit
color, will fail
graphicsmode -1 100: 1000 100: 1000
Use vbe mode, the maximum available resolution width
selected from the range of 100 to 1000, the maximum available height selected
from the range of 100 to 1000
That is, the above command optional 320 × 200,320 ×
400,640 × 400,640 × 480,800 × 600 resolution, etc., from which to select the
highest resolution available
graphicsmode -1 100: 1000 100: 1000 24:32
Effect as above, but adds depth range of colors, the
same, choose the highest color depth available in 24 colors and 32 colors in
[Note: grub4dos the vbe does not support 16-bit color
depth and a lower, only supports 24-bit and 32-bit color depth. So, all of you
graphicsmode command, you need to explicitly specify the color depth 24:32, can
not be omitted. For example, the use of graphicsmode -1 and graphicsmode -1 800
600 is not entirely correct, it should be replaced respectively graphicsmode -1
-1 -1 24:32 and graphicsmode -1 800 600 24:32 considered right. ]
==============================
vbeprobe
Detection vbe information
vbeprobe 1024x768x32
Detection vbe information specified ?? not supported ???
vbeprobe 0x100
Detection vbe information specified graphics mode
==============================
testvbe 800x600
Test specified vbe mode, direct calls sometimes Huaping
setvbe 800x600x32
Before running to change the core of the system video
mode, video mode information will be passed to the core. Huaping direct calls
in most cases
[Note: setvbe command is mainly to some Linux boot
process graphical interface and design, is not normally. Recommends that you
never use it. If you can avoid it, try to avoid using it. Linux is usually in
your own startup process, will set themselves the appropriate graphics mode,
rather than to go through the settings grub4dos job. Therefore, the future may
ban this setvbe command. ]
==============================
terminal console
Select the text-mode terminal
terminal graphics
Select the graphic mode terminals
terminal --no-echo graphics
Select the graphic mode terminals, and does not display
the characters entered by the user
terminal --font-spacing=1: 2
In vbe mode, set the kerning to a line spacing of 2
units: Like a few points.
[Note: For more on terminal usage does not know how to
use, it seems irrelevant. ]
==============================
terminfo
Display configuration information about the current
terminal
[Note: For more on the usage of terminfo not know how to
use, it seems irrelevant. ]
==============================
font /unifont.hex.gz
Load the font file that displays characters in vbe mode (file in hex format, can be compressed as gzip or LZMA)
default font height = 16 (may be 8 or 16 pixels wide)
font --font-high=24 /sft.f24
also --simp= for chinese (unsure how to use??)
Font Download:
https://code.google.com/p/grub4dos-chenall/
http://bbs.wuyou.net/forum.php?mod=viewthread&tid=256198
0.4.6a 2016 - supports larger fonts - e.g. 24 (max 32 - Warning: 32 high will use more memory above (md)0xA0000)
for fonts, download Easy2Boot (24-pixel high font files end in .f24)
==============================
background 303030
Set the background color in vga mode, the other modes do
not work
foreground FFFF00
Set the foreground color in vga mode and other modes do
not work
==================================================
========================================
Part 3 - halt, reboot, hide, unhide, hiddenflag, makeactive,
partnew, parttype, blocklist, uuid, fstest
halt
Shutdown (halt, there are many parameters, when something
goes wrong when you go off to study its parameters it)
reboot
Reboot (no arguments)
hide (hd0,0)
Hide the first hard disk first primary partition
unhide (hd0,0)
Unhide the first primary partition of the first hard disk
==========
hiddenflag
Displays the hidden status of current root device
(for ud, cd, etc. do not work)
hiddenflag (hd0,0)
Displays the first hard disk hidden status of
the first primary partition
hiddenflag --set
With the current device to hide
hiddenflag --set (hd0,0)
The first hard disk first primary partition is set to
hide (ie, if the original partition type is 0x07, now partition type 0x17)
hiddenflag --clear
The current device is set to unhidden
hiddenflag --clear (hd0,0)
The first hard disk first primary partition is set to
appear (that is, if the original partition type is 0x17, now partition type
0x07)
==============================
makeactive
The current device is set to active
makeactive (hd0,0)
The first hard disk first primary partition as active
makeactive --status
Show whether the current device is active
makeactive --status (hd0,0)
Displays the first hard disk is the first primary
partition as active
==============================
partnew [--active] partition type starting-sector number
[length]
or
partnew --active partition type CONTIG_FILE
creates a new primary partition table entry with values corresponding to the start-sector+length or file-start+length
e.g.
partnew --active (hd0,3) 0 /_ISO/ubuntu.iso
sets a partition of type 0 to start of ubuntu ISO - this partition will be automatically found and mounted by linux as CD filesystem.
If type=0 (or 0x10 for hidden) then the partition type will be set automatically depending on file contents or type 0 if not.
==============================
parttype
Display the current partition partition type
parttype (hd0,0)
Display the partition type of the first hard disk first
partition
parttype (hd0,0) 0x17
The type of the first partition of the first hard disk
partition to 0x17
==============================
blocklist /grldr
Show file information block, ie the starting block and
the block length of the local file.
blocklist file pxe command can not be used on the device.
[Note: If a file is fragmented, blocklist file lists all
the blocks, including debris, if too much debris beyond Grub4Dos buffer, the
command will fail]
If small NTFS file, then first (attribute $MFT) block is not reported.
==============================
uuid
Column number at all devices uuid
uuid (hd0,0)
Uuid number designated display device
uuid 000E0336000C1B8D
Find uuid number 000E0336000C1B8D equipment, and set it
to the current device
uuid (hd0,0) 000E0336000C1B8D && echo yes! echo
no
If (hd0,0) The uuid number 000E0336000C1B8D output yes,
otherwise no output
==============================
fstest
Order to help developers create file system supports code
set, end users do not need it.
==================================================
========================================
Part 4 - kernel, initrd, module, modulenounzip, chainloader, boot,
pxe, quit
kernel [--no-mem-option] [--type=TYPE] FILE [ARG ...]
Try to load the master boot image file. Other items will
be used as the kernel command line parameters passed to the kernel.
Before using this command, the kernel used by the module
should be reloaded.
--type Parameter for describing the kernel types,
including "netbsd", "freebsd", "openbsd",
"linux", "biglinux" and "multiboot".
--no-mem-option parameters for describing the Linux
memory need not automatically pass mem parameter to linux
==============================
initrd FILE [FILE ...]
Initialize the virtual disk to load Linux format, and set
the necessary parameters. Specify start before the real root file system
access, access ramdisk images in the system.
By the following command to start the kernel and initrd
Ubuntu 13.10 LiveCD:
# Menu Title
title starts Ubuntu 13.10 amd64 LiveCD
# Find UBUNTU-13.10-X64.ISO where disk and set it as the
current disk
find --set-root /BOOT/UBUNTU/UBUNTU-13.10-X64.ISO
# Try to load the master boot image file vmlinuz.efi,
followed by the parameters passed to vmlinuz.efi.
kernel /BOOT/UBUNTU/vmlinuz.efi boot=casper iso-scan /filename=/BOOT
/UBUNTU /UBUNTU-13.10-X64.ISO locale=zh_CN.UTF-8
# Load Linux virtual disk initialization format
initrd.lz.
initrd /BOOT/UBUNTU/initrd.lz
==============================
module FILE [ARG ...]
For multiple boot image file to load the startup module
(not handle the contents of the file, the user must determine their own core
requirements).
The remaining arguments as "fast-mode
command-line" pass, like kernel command.
This command is typically do not have access, when you
want to start when the Linux system, and the system requirements for the load
module file, will be used, related to the Linux system will be described, the
average user can ignore this command.
==============================
modulenounzip FILE [ARG ...]
Similar to the module, but disabled the automatic
decompression.
As above, the average user can ignore this command.
==============================
chainloader /ntldr
Load ntldr boot file
chainloader (hd0,0) +1
Load (hd0,0) first sector
chainloader +1
Load current of the first sector of the device
chainloader --force (hd0,0) +1
Load (hd0,0) in the first sector, the sector started to
ignore the validity of identity, forced to start
[Note: chainloader there are many other parameters can be
modified before the start of the CPU registers, but for the average user, these
things will not be used, if you want to know more chainloader parameters, refer
to "Grub4Dos 0.4.5c of help documentation "]
==============================
boot
Boot loaded operating system or chain loader sector, OK
to start, usually with the use chainloader command in the menu file can be
omitted, the command line mode requires.
chainloader /ntldr
boot
Load ntldr boot file, and then start.
boot -1
Call the BIOS int18 function, according to BIOS boot
order set to start next device.
boot --int18
As above, call the BIOS int18 function, according to BIOS
boot order set to start next device.
==============================
pxe
This command is more complex, later studies, the first
local start to get to know.
==============================
quit
If you are entering the GRUB environment from DOS
environment, use this command to return to the DOS environment.
quit --disable-a20
Use --disable-a20 parameter A20 line will be closed when
the transfer control to DOS.
==================================================
========================================
Part 5 - configfile, default, savedefault, timeout, title,
iftitle, hiddenmenu, password, lock, md5crypt, commandline, gfxmenu,
splashimage, color, outline
Use the command line or menu file:
configfile /menu.lst
Load current menu file in the root directory of the
device /menu.lst.
configfile (hd0,0) /menu.lst
#load (hd0,0) /menu.lst
configfile (md)4+8
Special usage, use grldr built-in menu. (md)4 is start of embedded menu.lst file.
To reset default config file path to use the built-in menu :
write 0x307ff8 1 && configfile
[Note: configfile command is executed, the current device
and the current directory will be updated at the same time as the device FILE
file.
If configfile command without any parameters in the initialization of the
built-in menu command group, then control is transferred to the menu.lst file to
start the device. ]
configfile
Load the last used configuration file (or \menu.lst from the current root)
==============================
Before use all menu items:
default 0
The first menu item is selected by default (if the user
does not manually select words)
default saved
The default selection is set to the last savedefault saved menu item
(savedefault executed in menu item, the default saved to /default file)
default /FILE
The default selection is set to the last savedefault save menu item
(savedefault executed in menu item, the default saved to /FILE file)
e.g. default default is often used where default is a 2048-byte file.
[Note: /default file or /FILE file must be 2048 bytes in size]
==============================
Used in the menu items:
savedefault
The current menu item as the default menu is saved to /default
or the default command to specify the /FILE in.
savedefault --wait=5
The current menu item to save as the default menu /default
or the default command to specify the /FILE, the first five seconds to save the
user a hint:
About to write the entry number x to file
Press Y to allow or N to deny.
If the user does not press the Y button, the default
within five seconds does not save menu item.
==============================
Before use all menu items:
timeout 10
Menu list appears after 10 seconds, if the user does not
manually select the default menu item to perform.
==============================
title menu title
Specifies the text of the menu item title
title menu title \ n menu prompts the first line \ n menu
prompts the second line \ n ...
The title text and text prompts to specify the menu item
[Note: If the menu item does not start sensitive command,
the menu key to select the vertical direction is not only key to select the
right direction. ]
Start sensitive command:
boot, chainloader, configfile, command, commandline,
halt, kernel, pxe, quit, reboot
You can do the following in the menu list interface:
e: Edit the current boot menu items
b: Start the current menu item
c: enter the grub command line
p: enter password (if set)
You can do the following in the Edit menu item:
e: Edit the current row
d: Delete the current line
o: insert a new row below the current row
O: to insert a new row above the current row
b: Start the current menu
c: enter the grub command line
esc: Returns the grub menu list, cancel any changes made
to the current menu item
[Note: The changes to the menu's only temporary, only
valid for this start]
At the command line you can do the following:
esc: Returns the grub menu list
In the menu list, you can press the number keys to select
the menu, if you want to select a menu item 9 above, you can press the number
key twice, for example, to select the first 25 menu items, you can press 2 and
then press 5 (menu number from 0 began, that number is zero first menu).
==============================
iftitle [if exist (hd0,0) /bootmgr] start (hd0,0) in
NT6.x
If [] the condition is TRUE then display the menu else do not display the menu
There must be no space after [ character or before ] character.
==============================
Before all menu items:
hiddenmenu 3
Does not display the menu list, use the menu item 3 start
within the timeout time, press any key to display the menu list.
hiddenmenu --chkpass=0x5700
Does not display the menu list, use the default start
menu items, within the timeout time press the F11 key to display the menu list.
[Note: If you do not know the key code can use pause
--test-key command to get the function]
==============================
Used in menu items, or until all the menu items:
password password
Lock on the menu, look at the following example:
title menu title
password 123
commandline
To do this you need to enter the password menu 123
title menu title
password --md5 $1$JS/2$CKT61E11gzkdEKQnEpqjhS1
commandline
To do this you need to enter the password menu 123 (123
is the result of md5 password encryption)
timeout 10
default 0
password 123
Menu 1 title
commandline
Menu 2 title
commandline
Locking the entire menu list, the menu list is not locked
after pressing the e key to edit, you can not press the c key to enter the
command line, you can use these features unlocked at the menu list interface,
press p key to enter the unlock password .
[Note: To get the md5 encoded string, you can perform
md5crypt 123]
==============================
Used in the menu items:
lock
Lock the current menu, to enter after the need to unlock.
Look at the following examples:
timeout 10
default 0
password 123
Menu 1 title
lock
commandline
Menu 2 title
commandline
Unlock the front, "Menu 1" can not be executed. After unlocking by pressing p and entering the password, "Menu 1" and
"Menu 2" can be executed
==============================
Used in the command line:
md5crypt abc
Gets a string abc of md5 encoded.
==============================
Used in the menu items:
commandline
Grub4Dos enter the command line.
==============================
Before use all menu items:
gfxmenu /message
Use /message graphic menu
Because gfxmenu compatibility with Grub4Dos bad, so I do
not recommend the use of
==============================
splashimage: display a bitmap or jpg.
Before use all menu items:
In
vbe mode, you can use 24-bit color or 32-color BMP or JPG format (not XPM in latest versions) format picture
as a background.
splashimage:splashimage [--offset=[type]=[x]=[y]] FILE
type: bit 7:transparent background
splashimage --fill-color=[0xrrggbb]
splashimage --animated=[type]=[duration]=[last_num]=[x]=[y] START_FILE
type: bit 0-3:times bit 4:repeat forever bit 5:wait time bit 7:transparent background type=00:disable
duration: [10] unit is a tick. [10:ms] units are milliseconds,
naming rules for START_FILE: *n.??? n: 1-9 or 01-99 or 001-999
hotkey F2,control animation: play/stop.
Load FILE as the background image when in graphics mode.
bmp or jpg can be compressed using gzip or grub4dos LZMA utility.
Progressive format JPEG files not supported (use MSPaint to re-save it). XPM no longer supported.
fill-color will fill the whole screen with a single rgb colour
For fastest animation - add bitmaps to a floppy.ima file and load to memory
map --read-only --mem /_ISO/DNA.ima (fd3)
map --hook
splashimage --animated=0x90=1=120=550=0 (fd3)/DNA_orbit_animated_frame_0001.bmp
==============================
Before use all menu items:
color normal=0xFFFFFF highlight=0xFF0000
Set menu is not selected for the white, select the menu
for the red
color heading=0x0000FF helptext=0x00FF00
Color information is provided in the top menu is blue,
the color information of the Help menu is green
color standard=0xFFFFFF
Set the text color to white console
color border=0xFF00FF
Set menu border color magenta (VBE mode active)
color normal=0xFFFFFF highlight=0xFF0000 heading=0x0000FF
helptext=0x00FF00 standard=0xFFFFFF border=0xFFFF00
All of the above and set the color
color 0xFFFFFF 0xFF0000 0x0000FF 0x00FF00 0xFFFFFF
0xFFFF00
All of the above and set the color (if the order is set,
you can omit the state flag)
color 0xFFFFFF 0xFF0000
Set menu is not selected for the white, select the menu
for the red (if the order is set, you can omit the state flag)
[Note: 0xFFFFFF represents the three colors red, green
and blue values: 0xRRGGBB]
==============================
Before use all menu items:
outline on
Open the outline of a character display mode graphics
mode.
outline off
Character outline closed graphics mode display mode.
outline
Character contour switch graphics mode display mode.
outline status
Character outline shows the current graphics mode display
mode.
[Note: Since the background when the cause is unclear
handwriting when you can try to open the show, it will get better display
effect]
==================================================
========================================
Part 6 - call, exit, shift, goto, set, setlocal, endlocal, if,
checkrange, errorcheck, errnum, fallback, pause, command, insmod, delmod
call: Label 1 Parameter 1 Parameter 2 ...
Go to the "Label 1" line and execute: eof
office returns, by goto: eof or exit can jump to: eof place.
! BAT # Note:! Header BAT is necessary, which is used to
identify a batch script Grub4Dos
# Save this file as test, and then enter the command line
test Grub4Dos execute it
call:! label1 Parameter 1 Parameter 2 Parameter 3
Parameter 4 Parameter 5 Parameter 6 && echo ok echo fail
call:! label2 Parameter 1 Parameter 2 Parameter 3 Parameter
4 Parameter 5 Parameter 6 && echo ok echo fail
end echo script
exit
: label1
echo% 1% 2% 3% 4% 5% 6% 7% 8% 9
exit 0
: label2
echo% 9% 8% 7% 6% 5% 4% 3% 2% 1
exit 1
Label1 call and get the return value, the return value is
displayed ok or fail
Label2 call and get its return value, the return value is
displayed ok or fail
label1 always returns true
label2 always returns false
call can refresh the environment variables into a new
environment, such as the following code:
iftitle [find --set-root --devices=h /bootmgr &&
call set bootmgr=%@root^%] load BOOTMGR of Windows VISTA /WIN7 /WIN2008 on %bootmgr%
If not call the --set-root can not take effect
immediately.
Also note here that the entire command line is parsed
before execution, parsing process, which will be replaced with the actual value
of the variable. %@root^% wording is to prevent parsing command line when it
is extended to the actual value, but to extend it to a string% @ root%, so that
the next time resolve to continue to expand. Time when the find --set-root
--devices=h /bootmgr executed successfully, you need to perform && call
set bootmgr =% @ root ^% (% @ root ^% at this time has been extended to %@root%) of , but also the implementation of a resolution, this time will be %@root% expands to the actual value.
==============================
exit
Jump to the script file: eof at (the end of the script
file). Function with goto: eof
==============================
shift
Batch-specific, discarding the first argument, the
following parameters to move forward.
shift 3
Batch-specific, discarding the third parameter, the
following parameters to move forward.
[Note: Grub4Dos can use the% 1 to% 9 parameters, which
means that all the parameters% remaining 9]
==============================
goto :label1
Batch files only, go to the "Label1" at the
execution, does not return, do not support arguments. Max label length 8 characters.
Later 2018 versions may support goto if used under a menu title or iftitle entry and can use variable, e.g. goto :%RET%
Must always precede label with colon.
Max 128 labels per batch file.
goto 3
Go to the menu item and run immediately. Used in menu files only.
Must use errorcheck on (does not work if errorcheck off).
e.g.
errorcheck on
goto 3
goto +1
Go to the next menu entry (can use -n or +n)
==============================
set
variable names max 8 characters
set a=123
Setting a value of a string variable 123
set /a a=123
Setting a value of decimal integer variable 123
set /A a=123
Set the variable a hexadecimal integer value 0x7B
set /a a=123 + 4
Setting variables a decimal integer value 127 (refer to
calc command)
set /A a=123 + 4
Set the variable a hexadecimal integer value 0x7F (refer
calc command)
set a
Show the value of a variable
set a =
To delete a variable
set *0x8280=0x80
Set integer value at memory address 0x8280 0x80
set
A list of all the variables listed
set *
clears all variables
set * && set fred=%fred%
clears all variables except fred
set a=abcdef
set len_a =%@retval%
%@retval% length by taking the last set of variables
set a=abcdef && set /a len_a=*0x4cb00
Length *0x4cb00 get through the last set of variables
[Note: The variable name up to eight characters, variable
content of up to 512 bytes, only 60 variables can be set]
set /p ask=Please enter a word :
prompt for input
set /p:3 ask=Please enter a word within 3 seconds :
prompt for input, with timeout
==============================
setlocal and endlocal
Variables and endlocal setlocal between local variables,
see the following examples:
set a=123
setlocal
set a=4
echo %a%
endlocal
echo %a%
endlocal between setlocal and assigned to a 4, but this
does not affect the variable before setlocal set a, after endlocal, a recovery
value of the variable before 123.
setlocal @ and endlocal @
Variables and endlocal setlocal between local variables,
setlocal @ and endlocal @ across script file exists.
[Note: setlocal @ setlocal will fail before, setlocal
setlocal @ After cross-script. ]
endlocal && set fred=%fred% && set doris=%doris%
sets fred and doris after endlocal
==============================
if #%a%==#123 echo ok
If the value of a variable equal to 123 output ok
if #%a%<=#123 echo ok
If the variable is equal to a value of less than 123
output ok
if #%a%>=#123 echo ok
If the variable is equal to a value greater than 123
output ok
Note: if 0f>=0g echo ok does not work correctly, when comparing strings or numbers+strings, ensure first character begins with a non-numerical character - e.g. #0f>-#0g
if #%a%>=#abc echo ok
If the value of a variable equal to the output string abc
ok (case-sensitive)
if /i #%a%>=#abc echo ok
If the value of a variable equal to the output string abc
ok (ignoring case)
if #%a%==# echo ok
If the variable a value is empty then the output ok
if #%a% == # 123 && echo ok
If the value of a variable equal to 123 output ok
if #%a%==#123 || echo fail
If the variable is not equal to a value of 123 outputs
fail
if not #%a%==#123 echo fail
If the variable is not equal to a value of 123 outputs
fail
if exist a echo ok
If there is a variable output ok
if not exist a echo fail
If there is a variable output fail
if exist /grldr && echo ok ! echo fail
If the file /grldr output ok, otherwise the output fail
Determine the existence of a file or directory on the
drive is invalid, for example (ud) /:
if exist /FILE && echo file or directory exists ! echo
the file or directory does not exist
Determine whether a file exists: (may not work on all filesystem!)
cat --length=0 /FILE && echo file exists ! echo
file does not exist
Determine whether there is a directory on the drive is
invalid, for example (ud) /:
cat --length=0 /FILE && echo directory does not
exist || if exist /FILE && echo directory exists! echo directory does
not exist
==============================
checkrange range command && success ! failure
If the "order" of the return value in the
"range" then "success", otherwise "failure."
checkrange 23 calc 20 + 3 && echo ok! echo fail