Grub4dos Windows 10
After several failed attempts to dual-boot Ubuntu 15.04 and Windows 10 on a single hard drive and on a computer with UEFI firmware, and not knowing what caused the first failed attempt, I figured that subsequent failed attempts must have been due to an existing Ubuntu GRUB folder in the Boot EFI folder.
Grub4dos Command Primer. Grub4dos Internal variables, memory areas, advanced features and function calls. 134 - Configure Windows to boot to grub4dos using the BCD. 135 - How to MBR-boot to a Windows 8/10 3TB+ hard disk. 136 - UEFI-boot directly from Ubuntu-based ISO files. How to install Windows 10 from Windows XP without using DVD or USB stick. How to install Windows 10 from Windows XP without DVD or USB stick.
Especially since the machine always froze when the installer is attempting to install GRUB
So I thought that If I could just delete the ubuntu folder from the Boot EFI folder, that the installation would complete – successfully. Ultimately, it didn’t, but I figured out how to delete GRUB files from inside Windows 10, from the command line.
This post documents how it was done. It involved, from the command line, listing and selecting the detected hard drives, listing the partitions on the hard drive, then, finally, listing and deleting the target folder. Another reason you might want to do this, is if you deleted the Linux partitions, which would not automatically delete the GRUB files from the Boot EFI folder.
To start, log into Windows 10, click on the menu and type cmd. Then right-click on the terminal application’s icon and select run as administrator. Figure 1 show the commands (underlined) used to accomplish the first step – listing and selecting the hard drive. To make it possible to copy-and-paste, for those who might need to, I’ve provided the commands in the code block after the last image.
In this figure, the target disk is shown as a 465 GB hard drive, with GPT partition.
After the target disk has been selected, its partitions are listed, so that the partition (volume) that corresponds to the Boot EFI folder can be identified. In Figure 2, that partition is Volume 2. It’s usually the only volume with FAT32 in the Fs (file system) column, and System in the Info column. After it has been identified and selected, you assign it a drive letter to make it easier to work with. In this example, I assigned it a drive letter D. After that, exit diskpart.
The final task involves changing into the Boot EFI folder, listing its contents to identify what subfolder the GRUB files would be. It will be in the EFI folder. The GRUB files for the distribution that was installed will be under a folder of the same name as the distribution. For example, if Ubuntu was installed, as in this example, the name of the folder will be ubuntu. Delete the folder using the rmdir /s command. That’s the Windows 10 equivalent of the Unix/Linux rm -r command.
All the commands used are given in this code block. Note that this procedure is not necessarily the best or only way to go about do this, so if you know of a better method, post a comment.
1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 | ## These commands are used to identify and select the hard drive diskpart list disk sel disk ## These commands are used to list the partitions, select the Boot EFI partition, ## These commands are used to change into the Boot EFI folder and delete the GRUB folder cd/dD: ls lsEFI cdEFI ls rmdir/subuntu |
Related Posts:
The following was translated by GoogleTranslate 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
- 10 Part 8 - Batch files and notes
Numbers
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 dircommand under Dos, list files and directories in the current directory (workingdirectory) under
ls /boot
Lists the current directory (working directory) undernames beginning with boot files and directories, do not use ls boot, it is onlyvalid in the root directory.
ls /boot /
Lists the current directory boot directory of files anddirectories, 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, thenthe 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 currentdirectory (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! echonot 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 concernedthat the folder does not exist. ]
[Note: Due to the illusion of the file name of thedirectory, 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 listall 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 /ntldrfile and list partitions found.
find --set-root /ntldr
Finds equipment /ntldr file, the device is set to firstfound device, the current device is searched first.
find --set-root --ignore-floppies --ignore-cd /ntldr
Finds equipment /ntldr file, the device is set to firstfind the current device. Ignore the floppy and CD-ROM.
find --set-root --devices=upnhcf /ntldr
Finds equipment /ntldr file, the device is set to firstfind the current device. Specify search order: ud, pxe, network equipment, harddisk, 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 firstfind the current device. Specifies the search order, and ignore the floppy andCD-ROM.
find --set-root ls /grub/
Finds /grub/ directory of the device, the device is setto first find the current device. /grub /directory can not be empty, otherwiseit 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 workingdirectory 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 directoryis /
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 thecurrent 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 thesame 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 canaccess the disk area, but still need to set the right circumstances the rootpartition. Some parameters need to be installed in order to determine thepartition may be a problem.
The following commands can be executed correctly, butwould 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 newvirtual hard disk after the last hard disk, BIOS disk count will be incremented +!
(cd0) first drive, equivalent to (hd32), --init createdby 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, whileoptical devices on the market almost all been replaced by U disk, so (cd?) Thisformat 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 harddrive, 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 anddrive)
(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 nolonger exists and has been replaced by pd)
(md) memory drive, to achieve the whole memory as a diskdrive to visit
(rd) random storage drives.
(md) device accesses memoryfrom physical address 0, has 512 byte 'sectors'
(rd) can be accessed starting at any base memoryaddress
Named in digital equipment:
fd0 - fd126: 0x0 - 0x7E (virtual floppy diskettes andexclude 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 harddisks)
cd: 0x9F (captured bootable CD, this is not necessarilycorrect, depending on the bios may be)
hd32 - hd127: 0xA0 - 0xFF (CD and virtual CD-ROM)
+1 Indicates the rest of the device following the firstsector of a device as a single file view:
(hd0)+1 will be the first sector of the entire hard diskas a file (of a sector)
(hd0,0)+1 will be the first sector of the partition as awhole file (of a sector)
(fd0)+1 will be the first sector of a floppy disk as awhole file (of a sector)
(cd0)+1 will be the first sector of the entire disc as afile (of a sector - sectors usually 2048 bytes)
(md)+1 will be the first sector of the entire memory asa file (of a sector)
(rd)+1 this rather special, all the contents of thespecified memory as a file
[Note: (rd)+1 This always represent the file, whichcontains all the bytes are stored in the (rd) ]
Can also use + 2, + 3, etc., represents the first twoor first three sectors viewed as a single file:
(hd0)+2 first two sectors entire hard disk as a file (oftwo sectors)
(hd0,0)+3 first three sectors throughout the district asa file (a total of three sectors)
(fd0)+5 entire first 5 sectors of the floppy disk as afile (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 theentire 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 wholefloppy 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 afile (a total of 32 sectors)
(rd)0+1 is equivalent to (rd) +1, all the contents ofthe specified memory as a file
About the (rd) Device:
(rd) devices only references the memory region, the memoryarea (rd) device is not being referenced protected, you can (rd) be interpretedas 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 isno (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 followingaddress:
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 thefollowing 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.ISOmust be continuously stored in the disk can not be fragmented.
map /win.vhd (hd)
map --hook
Map file as next available hard disk and increment BIOS hard disk count.
BIOS hard disk count is incremented if new disk is last BIOS disk+1
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 gzipcompression, but not both achieve.
In grub4dos, the memory is divided into at 3.25G highmemory and low memory ends 3.25G mirroring can not cross this point. If yourmemory 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 upmemory, equivalent --unhook then --hook (so it seems, map --unhook command doesnot 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.IMGfile is corrupted.
Mapped to emulate disk files can all be modified, whetherit 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, butnot 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
Allowmodification 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.
Chennai gana video song download. 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 styleof writing is interpreted as representative of the (hdm, n) partitions, ratherthan 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 + nonescape 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 theprevious 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, justreplace the three former results found
cat --locate=abc --replace=def --locate-align=16/menu.lst
Find the abc string /menu.lst and replaced def, replaceonly 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 addressoffset 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 && echoexist ! echo not exist
/menu.lst Determine whether there is a file, if itexists, 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 (255 decimal), exceeding the 377 code will then be convertedmodulo 377, for example, 400 represents 0
xnn a 2-digit hexadecimal chracters (0-9 A-F) (x00-xFF) code indicates thatthe 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 =, youcan 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 /aLast =%?% > 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 resultsdisplayed in hexadecimal format.
cmp /menu.lst /m.lst > nul && echo same ! echo different
Compare two files are the same, if the same, then theoutput 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.lstin. When copying, skip the first five blocks /menu.lst, and start reading fromthe first 6 blocks, a write, skip the first seven blocks /m.lst from the firsteight 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 whencopying from 0x2000000 position memory (32M location) take 0x2000000 space (32Mspace) as a cache for copying large files, increasing the cache size dd canaccelerate write speeds.
[Note: The source and target files must be present, thepath must begin with a device name, the excess length of the file will bediscarded, the target file can not be gz compressed files, source files can becompressed gz files, compressed files before replication be extracted. dd forthe entire device can read and write operations: dd if=(fd0) of=(fd1), withcaution. ]
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 thebeginning of the space, other spaces, or single or double quotation marks donot need to escape, escape can be processed, the backslash must be escaped]
[Note: The target file must exist, some beyondthe length of the file will be discarded, the target file can not be gzcompressed files, source files can be compressed gz files, compressed filesbefore copying will be extracted. write commands to operate the equipment:write (fd0) abc, caution. ]
write --bytes=20x8274 0x2001
If the object is not written to a file or device, but anumber, this number represents a memory address, the address of the memory datawrite modified to specify the value of the data to be written must be aninteger, 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 x00x01x02 where bytes n = 1-8
If target is FILE (not ADDR) then must specify byte string x00x01 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 isnow as follows:
00000 ~ 0FFFF occupied grub4dos program code and stack.
10000 ~ 1FFFF grub4dos future for code and dataretention.
20000 ~ 2FFFF is grub4dos geometry kernel automaticallydetect occupancy, as a buffer.
30000 ~ 37FFF occupied grub4dos kernel conventional diskread 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 bufferoccupancy.
[Note: The above content on memory allocation is notnecessarily 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 to1
calc *0x50000=*0x8280
The integer value stored at the memory 0x50000 change to theinteger value stored at 0x8280
calc *0x50000=1<<4
The integer value stored at the memory 0x50000 modify theresults of the calculated (1<<4=16)
[Note: In the set /a var=value in, value can becalculated using the above method: set /ab=*0x8280]
calc and set /a minus number can be treated as a negative, butto 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 of0--32, with the following wording can be calculated (add a space after theminus 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 differenttime. (Checktime points during the week day month)
checktime * * * * 6,0 && echo weekend ! echoWeekday
Display different information according to differenttime. (Checktime points during the week day month)
checktime * * * * * /2 && echo Fortnight ! echosingle week
Display different information according to differenttime. (Checktime points during the week day month)
checktime 0,1-59/15 * * * * && echo wholequarter of an hour ! echo quarter non-integer
Display different information according to differenttime. (Checktime points during the week day month)
echo Hello
Output on the screen Hello (end of the line willautomatically add line breaks)
echo -n Hello
Output on the screen Hello (end of the line does notautomatically add a newline)
echo -e Hello
Output on the screen Hello (-e that handles the escapecharacter)
echo -h
Echo display color table support
echo $[0x1F]abc
Use color table 1F at foreground and background colorsdisplay abc
echo $[0x1F]abc$[0xE4]def
Use color table 1F at foreground and background colorsdisplay abc, then use the foreground and background colors of the color tableE4 def display
echo $[0104]abc$[]fred
Display abc in red and fred in current console colour. Bug: $[] must always be followed by a character or space or else strange characters are output.
echo $[0xFFFFFF00FF0000]fred
Display fred in red text on white background
echo -P:0101 abc
abc displayed in the first row and first column of thescreen (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 thescreen)
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 goodfor some, there may be crashes), recommended vbe mode
graphicsmode -1 640
Use vbe mode, specify the resolution width of 640, if thewidth of the monitor does not support this resolution will fail
graphicsmode -1 800 600
Use vbe mode, specify the resolution width of 800 and aheight 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, height768, 32-bit color, if the monitor does not support this resolution or bitcolor, will fail
graphicsmode -1 100: 1000 100: 1000
Use vbe mode, the maximum available resolution widthselected from the range of 100 to 1000, the maximum available height selectedfrom 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 thehighest resolution available
graphicsmode -1 100: 1000 100: 1000 24:32
Effect as above, but adds depth range of colors, thesame, choose the highest color depth available in 24 colors and 32 colors in
[Note: grub4dos the vbe does not support 16-bit colordepth and a lower, only supports 24-bit and 32-bit color depth. So, all of yougraphicsmode command, you need to explicitly specify the color depth 24:32, cannot be omitted. For example, the use of graphicsmode -1 and graphicsmode -1 800600 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 videomode, video mode information will be passed to the core. Huaping direct callsin most cases
[Note: setvbe command is mainly to some Linux bootprocess graphical interface and design, is not normally. Recommends that younever use it. If you can avoid it, try to avoid using it. Linux is usually inyour own startup process, will set themselves the appropriate graphics mode,rather than to go through the settings grub4dos job. Therefore, the future mayban 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 displaythe characters entered by the user
terminal --font-spacing=1: 2
In vbe mode, set the kerning to a line spacing of 2units: Like a few points.
[Note: For more on terminal usage does not know how touse, it seems irrelevant. ]
terminfo
Many PDFs that I read are scans and they are oriented horizontally. I can't read them without rotating them! Adobe reader download windows 10 64-bit.
Display configuration information about the currentterminal
[Note: For more on the usage of terminfo not know how touse, 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 donot work
foreground FFFF00
Set the foreground color in vga mode and other modes donot work
Part 3 - halt, reboot, hide, unhide, hiddenflag, makeactive,partnew, parttype, blocklist, uuid, fstest
halt
Shutdown (halt, there are many parameters, when somethinggoes 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 ofthe first primary partition
hiddenflag --set
With the current device to hide
hiddenflag --set (hd0,0)
The first hard disk first primary partition is set tohide (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 toappear (that is, if the original partition type is 0x17, now partition type0x07)
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 primarypartition 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 firstpartition
parttype (hd0,0) 0x17
The type of the first partition of the first hard diskpartition to 0x17
blocklist /grldr
Show file information block, ie the starting block andthe 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 allthe blocks, including debris, if too much debris beyond Grub4Dos buffer, thecommand 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 itto the current device
uuid (hd0,0) 000E0336000C1B8D && echo yes! echono
If (hd0,0) The uuid number 000E0336000C1B8D output yes,otherwise no output
fstest
Order to help developers create file system supports codeset, 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 willbe used as the kernel command line parameters passed to the kernel.
Before using this command, the kernel used by the moduleshould be reloaded.
--type Parameter for describing the kernel types,including 'netbsd', 'freebsd', 'openbsd','linux', 'biglinux' and 'multiboot'.
--no-mem-option parameters for describing the Linuxmemory need not automatically pass mem parameter to linux
initrd FILE [FILE2] [FILE..]
Initialize the virtual disk to load Linux format, and setthe necessary parameters. Specify start before the real root file systemaccess, access ramdisk images in the system.
By the following command to start the kernel and initrdUbuntu 13.10 LiveCD:
title starts Ubuntu 13.10 amd64 LiveCD
# Find UBUNTU-13.10-X64.ISO where disk and set it as thecurrent 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 formatinitrd.lz.
initrd /BOOT/UBUNTU/initrd.lz
Do not use multiple initrd lines for multiple image files, instead place all image files on same line, e.g. initrd /boot/file1 /boot/file2 /boot/file3
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 corerequirements).
The remaining arguments as 'fast-modecommand-line' pass, like kernel command.
This command is typically do not have access, when youwant to start when the Linux system, and the system requirements for the loadmodule file, will be used, related to the Linux system will be described, theaverage user can ignore this command.
modulenounzip FILE [ARG ..]
Similar to the module, but disabled the automaticdecompression.
As above, the average user can ignore this command.
chainloader
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 toignore the validity of identity, forced to start
[Note: chainloader there are many other parameters can bemodified before the start of the CPU registers, but for the average user, thesethings will not be used, if you want to know more chainloader parameters, referto 'Grub4Dos help documentation ']
Grub4dos Windows 10 Windows 7
boot
Boot loaded operating system or chain loader sector, OKto start, usually with the use chainloader command in the menu file can beomitted, 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 bootorder set to start next device.
boot --int18
As above, call the BIOS int18 function, according to BIOSboot order set to start next device.
pxe
This command is more complex, later studies, the firstlocal start to get to know. See http://diddy.boot-land.net/grub4dos/files/pxe.htm
The default, embedded menu in grldr contains pxe detect command - so grldr will automatically look for a PXE server and load a menu file from the server if one is found.
1. pxe
If used without any parameter, pxe command will display current settings.
2. pxe blksize N
Set the packet size for tftp transmission. Minimum value is 512,
maximum value is 1432. This parameter is used primarily for very old
tftp server where packet larger than 512 byte is not supported.
3. pxe basedir /dir
Set the base directory for files in the tftp server. If
pxe basedir /tftp
then all files in the pxe device is related to directory /tftp, for example, (pd)/aa.img correspond to /tftp/aa.img in the server.
The default value of base directory is the directory of the boot file, for example, if boot file is /tftp/grldr, then default base directory is /tftp.
4. pxe keep
Keep the PXE stack. The default behaviour of GRUB4DOS is to unload the PXE stack just before it exits.
Note: Do not use pxe keep if you first boot via PXE to grub4dos and then load grub4dos again to boot from a disk, otherwise grub4dos will just try to PXE boot again!
5. pxe unload
Unload the PXE stack immediately. Does not work if pxe keep has been used.
quit
If you are entering the GRUB environment from DOSenvironment, use this command to return to the DOS environment.
quit --disable-a20
Use --disable-a20 parameter - A20 line will be disabled whenthe 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 thedevice /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 deviceand the current directory will be updated at the same time as the device FILEfile.
If configfile command without any parameters in the initialization of thebuilt-in menu command group, then control is transferred to the menu.lst file tostart 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 userdoes 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 /defaultor the default command to specify the /FILE in.
savedefault --wait=5
The current menu item to save as the default menu /defaultor the default command to specify the /FILE, the first five seconds to save theuser 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 defaultwithin five seconds does not save menu item.
Before use all menu items:
timeout 10
Menu list appears after 10 seconds, if the user does notmanually 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 menuprompts 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 theright 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 madeto the current menu item
[Note: The changes to the menu's only temporary, onlyvalid 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 selectthe menu, if you want to select a menu item 9 above, you can press the numberkey twice, for example, to select the first 25 menu items, you can press 2 andthen press 5 (menu number from 0 began, that number is zero first menu).
iftitle [if exist (hd0,0) /bootmgr] start (hd0,0) inNT6.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 startwithin the timeout time, press any key to display the menu list.
hiddenmenu --chkpass=0x5700
Does not display the menu list, use the default startmenu 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 (123is 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 lockedafter pressing the e key to edit, you can not press the c key to enter thecommand 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 performmd5crypt 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 donot recommend the use of
splashimage: display a bitmap or jpg.
Before use all menu items:
Invbe mode, you can use 24-bit color or 32-color BMP or JPG format (not XPM in latest versions) format pictureas 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
Before use all menu items:
color normal=0xFFFFFF highlight=0xFF0000
Set menu is not selected for the white, select the menufor 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=0x0000FFhelptext=0x00FF00 standard=0xFFFFFF border=0xFFFF00
All of the above and set the color
color 0xFFFFFF 0xFF0000 0x0000FF 0x00FF00 0xFFFFFF0xFFFF00
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 menufor the red (if the order is set, you can omit the state flag)
[Note: 0xFFFFFF represents the three colors red, greenand blue values: 0xRRGGBB]
Before use all menu items:
outline on
Open the outline of a character display mode graphicsmode.
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 displaymode.
[Note: Since the background when the cause is unclearhandwriting when you can try to open the show, it will get better displayeffect]
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: eofoffice returns, by goto: eof or exit can jump to: eof place.
! BAT # Note:! Header BAT is necessary, which is used toidentify a batch script Grub4Dos
# Save this file as test, and then enter the command linetest Grub4Dos execute it
call:! label1 Parameter 1 Parameter 2 Parameter 3Parameter 4 Parameter 5 Parameter 6 && echo ok echo fail
call:! label2 Parameter 1 Parameter 2 Parameter 3 Parameter4 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 isdisplayed ok or fail
Label2 call and get its return value, the return value isdisplayed ok or fail
label1 always returns true
label2 always returns false
call can refresh the environment variables into a newenvironment, 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 effectimmediately.
Also note here that the entire command line is parsedbefore execution, parsing process, which will be replaced with the actual valueof the variable. %@root^% wording is to prevent parsing command line when itis extended to the actual value, but to extend it to a string% @ root%, so thatthe next time resolve to continue to expand. Time when the find --set-root--devices=h /bootmgr executed successfully, you need to perform && callset 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 scriptfile). Function with goto: eof
shift
Batch-specific, discarding the first argument, thefollowing parameters to move forward.
shift 3
Batch-specific, discarding the third parameter, thefollowing parameters to move forward.
[Note: Grub4Dos can use the% 1 to% 9 parameters, whichmeans that all the parameters% remaining 9]
goto :label1
Batch files only, go to the 'Label1' at theexecution, 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 tocalc command)
set /A a=123 + 4
Set the variable a hexadecimal integer value 0x7F (refercalc 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, variablecontent 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 thisdoes not affect the variable before setlocal set a, after endlocal, a recoveryvalue 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, setlocalsetlocal @ 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 123output ok
if #%a%>=#123 echo ok
If the variable is equal to a value greater than 123output 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 abcok (case-sensitive)
if /i #%a%>=#abc echo ok
If the value of a variable equal to the output string abcok (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 outputsfail
if not #%a%#123 echo fail
If the variable is not equal to a value of 123 outputsfail
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 thedrive is invalid, for example (ud) /:
if exist /FILE && echo file or directory exists ! echothe file or directory does not exist
Determine whether a file exists: (may not work on all filesystem!)
cat --length=0 /FILE && echo file exists ! echofile does not exist
Determine whether there is a directory on the drive isinvalid, for example (ud) /:
cat --length=0 /FILE && echo directory does notexist if exist /FILE && echo directory exists! echo directory doesnot 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
If the value of 20 + 3 is in range of 23, the output ok, otherwise output fail
checkrange 0x21,0x23,0x80 read 0x8280 && echo ok !echo fail
If you read from 0x8280 a value of 0x21 or 0x23 or 0x80 then output ok, otherwise output fail
checkrange 0:100 calc %a% && echo ok ! echo fail
If the variable is a value between 0-100, the output ok,otherwise output fail
errorcheck on
Open the error checking, error is encountered terminatesexecution
errorcheck off
Close the error checking, error encountered in theimplementation will be ignored until it is finished
errorcheck
Switching error checking mode
errorcheck status
Displays the current error checking mode
[Note: errorcheck command controls whether the error isprocessed. Errorcheck is enabled by default, that is, when an error occurscommand script will stop executing. If errorcheck is off, the script has beenexecuted to boot command (ie under the off state, fallback commands will fail).A boot command to check into the wrong turn]
errnum
Returns an error code on a command. If the command is notan error, it returns an error code of 0, otherwise it returns an appropriateerror code.
fallback 3
If the current menu item execution error, thentransferred to the third menu item to proceed. This command is only used in themenu for unattended boot mode: If the menu item execution error, withoutwaiting for the user to operate, immediately jump to the first three menu itemscontinue to default.
pause
returns TRUE if a key is pressed or FALSE if ESC is pressed
pause Press any key to continue && echo A key was pressed ! echo ESC was pressed
pause press any key to continue
Continue to run the command after a pause, and give somemessage, press any key.
pause --wait=10 press any key to continue
Continue to run the command after a pause, and give somemessage, press any key. If you do not press any key within 10 seconds, thenautomatically return to the command line.
pause --test-key
After executing the command, press any key to display thescan code.
pause && set /a key=*0x4CB00 ! set key =
Pause command to run, after pressing any key to continue,and the keys are stored in the variable key in ASCII code. If you press the ESCkey, then delete the variable key. 0x4cb00 is BIOS data area location of last key press.
command
Displays the current location specified external command
command --set-path=/boot /grub
Specify the location of external commands /boot /grub
command RUN /pe.iso
Find RUN and execute external commands, parameters/pe.iso
command /boot /RUN /pe.iso
Execute external commands /boot /RUN, the parameters for/pe.iso
[Note: Look for an external command sequence is asfollows: If is '(' or '/' at the beginning of the file is considered to be anabsolute file path, otherwise it will be directly executed
Find command insmodloads then look in the current directory. the same name. then find --set-pathfile specify the location of the same name.]
insmod RUN
RUN command to load external memory, making reads frommemory when executing external commands directly, instead of reading from thesource device, faster execution.
insmod FILE.MOD
FILE.MOD is generated by using external command makemodcollection, eliminating cumbersome multiple use insmod to load an externalcommand. You can also use the tool to create FILE.MOD Fbinsttool file.
insmod /boot/grub/fat.gz fat
The external command fat.gz loaded into memory, andspecify the new name as fat, then you can directly use the fat to call thisexternal command.
[Note: insmod to load the file, the file name length mustnot exceed 11 characters. ]
delmod
Display loaded external command
delmod RUN
Unload loaded external command RUN
delmod *
Unload all loaded external command
delmod -l %~nx0 > nul insmod %0 > nul
Determine whether the current script has been loaded intomemory, if not, then it is loaded into memory.
Part 7 - help, debug, displaymem, geometry, is64bit, serial, tpm,setkey
help
Display a list of internal commands
help --all
Display a list of all commands
help root
Root command displays help information
debug off or debug 0
Turn on silent mode
debug normal or debug 1
Open standard mode
debug on
Turn on verbose mode, from debug 2 to debug 0x7fffffffare equivalent to (please use the debug report BUG this mode, you can get moredetailed information) debug on
debug -1
Hide Countdown Tips - e.g. with pause command
debug 3
Open the batch script debugging mode (single step), debugmode under 3 Press c to enter the command line, press Ctrl + c key combinationcan suspend execution of the script.
debug BATCHFILE PARAM1 PARAM2 PARAM3 etc.
debug the grub4dos batch file BATCHFILE. Can single-step, skip over, exit to command shell, etc.
Also, debug msg=N where N=0 (no message), 1 (stdout), 2 (errout) 3 (stdout+errout debug)
Also, debug BATCHFILE ARG1 ARG2 ARG3 ..
for single-stepping batch files: e.g. debug /test.g4b fred doris
Grub4dos Windows 98
displaymem
GRUB judged show the current memory distribution system,including all physical memory area.
Later versions show (example):
Usable RAM (HEX): 0+4F8 800+6DF2D0 800000+2A0000Numbers are hex 512-byte sectors: Usable memory in 3 chunks, starts at 0 for 4F8 sectors, then start at sector 800 for 6DF2D0 sectors, then starts at 800000 for 2A0000 sectors
Chunk #1 is 4F8*200 = 9F000 or 651,264 bytes in size, chunk #2 starts at 800*200 = 1MB and is DBE5A000 or 3689MB in size, chunk #3 starts at 4295MB and is 54000000 or 1409MB in size - so system has approx 6GB of RAM.
geometry (hd0)
Output (hd0) information.
is64bit
bit 0 set = 64-bit
bit 1 set = PAE
Returns 0 or 1 if 32-bit, 2 or 3 if 64-bit CPU
checkrange 0,1 is64bit && echo 32-bitcheckrange 0,2 is64bit && echo PAE not supportedserial
Initialize a serial device. Serial port, not research.
tpm --init
512 bytes of data as initialization TPM (Trusted PlatformModule) cache 7C00 at: 0000 in the address. Do not have access, not research.
setkey NEW_KEY USA_KEY
Pressing the USA_KEY produces the NEW_KEY.
e.g. setkey 9 1 - displays 9 if press 1 key
setkey 9 exclam - displays 9 if ! key pressed
setkey 9 at - displays 9 if @ key pressed
[Note: This key must be letters, numbers, and thefollowing special keys: escape (escape), exclam (!), at (@), numbersign (#), dollar ($), parenright ()), caret (^), ampersand (&), asterisk (*), plus (+), percent (%), minus (-), underscore (_), equal (=), parenleft [(], backspace (backspace), ctrlbackspace, tab (Tab), bracketleft ([), braceleft ({), bracketright (]), braceright (}), enter (carriage return), semicolon (;), colon (:), quote (') , doublequote ('), slash (/), backquote (`), tilde (~), backslash (), bar ( ), comma (,), less (<) period (.) , greater (>), question (?), space, home, uparrow, pageup, leftarrow, center, rightarrow, end, downarrow, pagedown, insert, delete,F1-F10, shiftF1-shiftF10, ctrlF1-ctrlF10.
Later versions (2019-05+) Add A for Alt+ codes, e.g. Aa-Az, A0-A9, Aequal, etc., also oem102 and shiftoem102 for the extra key on 102-key kbd.
setkey greater oem102
setkey less shiftoem102
setkey at Av
New 0.4.6a 2018-08 commands (setmenu, beep)
setmenu - controls placing and appearence of menu. keyhelp is the grub4dos edit prompts, entryhelp is the help text used in titles (after title xxxxn<entryhelp>)
setmenu:setmenu --parameter --parameter .. --ver-on* --ver-off --lang=en* --lang=zh --u
--left-align* --right-align --middle-align
--auto-num-off* --auto-num-all-on --auto-num-on --triangle-on* --triangle-off
--highlight-short* --highlight-full
--font-spacing=FONT:LINE. default 0
--string=[X]=[-]Y=COLOR='STRING' max 16 commands.
Note: there is no X, position in the middle.
Note: -Y represents the count from the bottom.
--string= to delete all strings.
--box x=X y=Y w=W h=H l=L
Note: W=0 in the middle. L=0 no display border
--help=X=W=Y
Note: X=0* menu start and width. X<>0 and W=0 Entire display width minus 2x.
--keyhelp=Y_OFFSET=COLOR
Note: Y_OFFSET=0* entryhelp and keyhelp in the same area,entryhelp cover keyhelp.
Y_OFFSET!=0 keyhelp to entryhelp line offset.two coexist.
Y_OFFSET<=4, entryhelp display line number.
COLOR=0* default 'color helptext'.
--timeout=X=Y=COLOR
Note: X=Y=0* located at the end of the selected item.
Note: COLOR=0* default 'color highlight'.
* indicates default. Use 0xRRGGBB to represent colors.
setmenu --graphic-entry=type=row=list=wide=high=row_space START_FILE
type: bit0:highlight bit1:flip bit2:box bit7:transparent background
naming rules for START_FILE: *n.??? n: 00-99
--u clear all.
--draw-box=INDEX=START_X=START_y=HORIZ=VERT=LINEWIDTH=COLOR.
INDEX:1-16; COLOR:24-bit color; LINEWIDTH:1-255; all dimensions in pixels.
--draw-box=INDEX to delete the specified index.
--draw-box= to delete all indexes.
2018-06-28 and later
beep
2018-06 and later - play tones [Frequency Hz] [Duration ms]
beep [--start --mid --end] [--play=N] [--nowait] FREQUENCY DURATION FREQUENCY DURATION ..
FREQUENCY: Hz. DURATION: ms. Max: 126 notes per command.
N: 0-255. 0 is stop play, 255 is continuous play (any key stops play).
When the syllable is a lot, can be written in different lines.
The use of [--start --mid --end] specifies parts of the same tune.
beep 200 500 0 100 300 500
beep --mid 330 440 330 220 392 220 440 220 522 220 522 220 440 220 392 440 392 220 440 220 392 880
beep --mid 392 440 392 440 392 440 330 220 392 220 440 440 440 440 392 880
beep --end --play=255 --nowait 293 660 330 220 261 220 293 220 261 220 220 220 196 1320
Part 8 - Batch files and notes
About !, &&, , ;; , & ;, ;
usage:
command1 && command2 ! command3
If command1 is executed successfully execute command2,otherwise execute command3
command1 command2 ! command3
If command1 fails, then execute command2, otherwiseexecute command3
command1 ;; command2 ;; command3
Three commands are executed sequentially refreshedafter;; environment variable. Equivalent to the following wording:
command1
command2
command3
command1 &; command2
If command1 is executed successfully execute command2,&; then will refresh the environment variables. Can not! Simultaneously.
command1 ; command2
If command1 fails, then execute command2, ; then willrefresh the environment variables. Can not! Simultaneously.
command1 && command2 command3
If command1 is executed successfully, execute command2 command3, nothing else to perform.
command1 && command2 command3 ! coommand4
If command1 is executed successfully, execute command2 command3, otherwise execute command4.
(Execute command2 command3 period, ifcommand2 fails to perform command3, otherwise execute command4)
In short: If you can not be successfully executed toperform the command4 command3
command1 &; command2 ! command3
Incorrect use, command3 never be executed
If command1 is executed successfully execute command2 !Command3, nothing else to perform.
command1 ; command2 command3!
Incorrect use, command3 never be executed
If command1 fails, then execute command2! Command3,otherwise nothing execution.
Tips:
If you find abc in /FILE, then set the Last to theposition last found, otherwise it is set Last to -1:
set Last=-1 && cat --locate=abc /FILE &; setLast =%?%
If you find abc in /FILE, the setting for the position ofFirst found first, otherwise it is set First to -1:
set First=-1 && cat --locate=abc --number=1 /FILE&; set First =%?%
About Pipeline Operation:
command1 command2 command3
The data output of command1 command2 as input, outputdata command2 as command3 input.
command1 > /FILE
Command1 output data will be written to /FILE in, /FILEany original data will be cleared.
command1 >> /FILE
Command1 will append data to the end of the output /FILE's,/FILE any original data is not affected.
Example:
echo -n 1 echo -n 2 echo -n 3
Equivalent
echo -n 21 echo -n 3
Equivalent
echo -n 321
echo -n abc > /test
The file /test the contents emptied, and write abc. File /test must exist and be > 1K if on NTFS filesystem
echo -n abc >> /test
Appended to the end of the abc /test for.
> >> And&& conjunction:
echo 1 > /test && echo 2 >> /test && echo 3 >> /test && cat /test
> >> And&& conjunction:
if 11 && echo 111 > /test && if 12 echo 222 >> /test && if 33 && echo 333 >> /test && cat /test
And && conjunction:
set /aa=1 echo -n && set /ab=2 echo -n&& set /ac=3 echo -n
2019-05 and later versions: echo -k used for finding scan code of key.
About batch scripts:
Batch script file must begin with! BAT to.
Batch script can exit by exit or exit a call to call,exit can return an exit code, such as exit 1
Batch script or call call can accept parameters:
%0 is the command itself
%* On behalf of all parameters (not including 0%)
%1-%8 represents the first one to the first eightparameters
%9 represents all remaining parameters
You can use the shift discard parameter, the defaultdiscard the first argument, you can pre-shift 6 dropped six parameters. Theremaining parameters will move forward.
%~d1 get the first argument disk number.
%~p1 gets the first argument path.
%~n1 gets the first parameter file name.
%~x1 get the first parameter file extension.
%~f1 gets the first argument the full file path(equivalent to %~dpnx1).
%~z1 get the first parameter file size.
In a batch script if multiple consecutive % when executedwill first replaced by a two percent (does not replace the command line):
Grub4dos Windows 7
set /a n=%a%%%b% when executed, would be replaced byset /a n=%a%%b%
Then will expand the variables a and b values ofvariables, when used in conjunction with a number of variables need to payattention.
Allows the use of Ctrl + C trap runtime batch execution.
Interception on a string variable:
set a=ABCDabcd1234
echo %a:~0%
0 + 1 from the beginning of the interception to the lastcharacter (ABCDabcd1234), equivalent% a%
echo %a:~0,2%
Start Capture from 0 + 1 characters, only interception ofthe next two characters (AB), the equivalent of% a: ~, 2%
echo %a:~0,-2%
Start Capture from 0 + 1 characters, intercepted twocharacters before the penultimate (ABCDabcd12), equivalent% a: ~, -2%
echo %a:~4%
4 + 1 from the beginning of the interception to the lastcharacter (abcd1234)
echo %a:~4,2%
4 + 1 from the first character start interception,interception followed only two characters (ab)
echo %a:~4,-2%
Start Capture 4 + 1 from the first character, theinterception of the penultimate two characters before (abcd12)
echo %a:~-4%
The first four characters from the beginning of thecountdown to the final interception (1234)
echo %a:~-4,2%
The first four characters from the beginning of thecountdown to intercept only interception of the next two characters (12)
echo %a:~-4,-2%
Start Capture from the penultimate four characters,intercepted the penultimate two characters before (12)
echo %a:~-4,8%
Start Capture from the penultimate four characters, onlyeight characters followed by interception (1234), the absence of so manycharacters for the interception, so only four interception.
About internal variables:
% @ retval%: Save the last command returns the value (iethe value at 0x4CB00)
if 11 ;; echo% @ retval%
Return 1 represents true (non-zero value represents true)
if 12 ;; echo% @ retval%
Return 0 for false
calc 100-1 > nul ;; echo %@retval%
The results returned 99
set a=abcdef ;; echo %@retval%
Return variable length 6
%?_ UUID%: Save uuid command to get to the UUID value
uuid (hd0,0) > nul ;; echo %?_UUID%
Output (hd0,0) UUID value
%?_BOOT%: Save the initial boot device device number
echo %?_BOOT%
If you boot from the CD, then the output (cd), if youstart from the ud, outputs (ud)
%@root% : Save the current device number for
root (hd0,0) ;; echo %@root%
%@path% : Find a path to save the external command
command --set-path=/BOOT /;; echo %@path%
%@date%: Get the current date
echo %@date%
%@time%: Get the current time
echo %@time%
%@random%: Get a random number
echo %@random%
%?% : Special variable, mean different things in differentplaces
cat --locate=abc /FILE
echo %?%
The output of the last position abc found
map /Floppy.img (fd0)
map --status=0
echo %?%
Output (fd0) starting sector 0x3D88A7
map --status=0
echo %@retval%
Output (fd0) the size of the 2880 (sectors)
Meaning some fixed memory address (set in front of my ownadded to facilitate the call):
set G_NBOOTP=0x8208 4 bytes (double word) boot partitionnumber install_partition (the boot partition)
set G_NBOOTD=0x8280 4 bytes (double word) to start thedrive letter (boot_drive)
set G_NROOTP=0x829C 4 bytes (double word) the currentroot partition number (current root partition)
set G_NROOTD=0x82A0 4 bytes (double word) where the rootof the current drive (current root drive)
set G_NCD=0x82C8 4 bytes (double word) CDROM drive letter
set G_NRD=0x82CC 4 bytes (double word) rd device driveletter
set G_RDBASE=0x82D0 8 bytes (ie four words) rd device'sphysical base address
set G_RDSIZE=0x82D8 8 bytes (ie four words) rd devicesize (in bytes)
set G_LFSIZE=0x8290 8 bytes (ie four words) last accessedthe file size (which is the implementation of 'cat --length=0' afterthe file size)
set G_LPSS=0x82A8 8 bytes (ie four words) starting sectornumber of the last visit of the partition
Total number of sectors set G_LPSC=0x82B0 8 bytes (iefour words) last visited partition
set G_VER=0x8278 4 bytes (double word) GRUB4DOS datecompiled a decimal number.
set G_IS64=0x82BC 4 bytes (double word) to detect whetherthe CPU supports 64
set G_ISFB=0x82B8 4 bytes (double word) to determinewhether the fb start
set G_FREEM=0x8298 4 bytes (double word) availableextended memory size (in KB)
set G_PXECIP=0x8284 4 bytes (double word) pxe client ip(ie local ip)
set G_PXESIP=0x8288 4 bytes (double word) pxe server ip
set G_PXEGW=0x828C 4 bytes (double word) pxe gateway ip
set G_AUTOM=0x8274 4 bytes (double word) menuautomatically numbered (for dynamic menus)
set G_AUTOMS=0x8275 4 bytes (double word) to enableautomatic numbering menu using the menu and automatic numbering betweendelimiters
set G_GZIP=0x82A4 4 bytes (double word) Unzip sign (gzipnon-automatic decompression), does not automatically extracting non 0:00
set G_SMH=0x82C0 4 bytes (double word) saved_mem_higher
Some implications of fixed memory address (removeinstructions section below):
set G_NBOOTP=0x8208
set G_NBOOTD=0x8280
set G_NROOTP=0x829C
set G_NROOTD=0x82A0
set G_NCD=0x82C8
set G_NRD=0x82CC
set G_RDBASE=0x82D0
set G_RDSIZE=0x82D8
set G_LFSIZE=0x8290
set G_LPSS=0x82A8
set G_LPSC=0x82B0
set G_VER=0x8278
set G_IS64=0x82BC
set G_ISFB=0x82B8
set G_FREEM=0x8298
set G_PXECIP=0x8284
set G_PXESIP=0x8288
set G_PXEGW=0x828C
set G_AUTOM=0x8274
set G_AUTOMS=0x8275
set G_GZIP=0x82A4
set G_SMH=0x82C0
Is recommended not to use the command:
cdrom: cdrom Because the success rate is too low, whilethe CD-ROM device on the market almost all been replaced by U disk, so cdromcommand may be phased out.
setvbe: usefulness, could face elimination.
background, foreground: only valid in vga mode andGrub4Dos vga mode is not recommended, but recommended vbe mode.
fstest: developer testing, most people do not have access
gfxmenu: not Grub4Dos management, compatibility withGrub4Dos bad, it is recommended not to use, and the use Grub4Dos recommendedvbe mode.
serial: serial, early eliminated.
Memory usage rules:
User can use (md)0x300-(md)0x3DF, or (md)0x1F40-(md)0x3FFF for larger area (approx. start at 4 up to 8M)
Improve the success rate of the method to start:
Ud make a boot disk with fbinst, fbinst can guarantee ahigh success rate of start.
Formatting fbinst, let grldr and menu.lst first put udarea, other documents on the back
The following quote 'no point' in the words:
The reason to read the disk failure are:
1, if there is no use grldr.mbr but directly using thepartition boot code, then, due to the partition boot code no ability toautomatically adapt the CHS, therefore, occurs in the case of BPB CHS can notmatch the motherboard BIOS CHS, and this may lead to int13 read the diskfailure or crash. If a PBR boot code does not use 'geometry detection andadaptive' approach, it must be placed in exactly the right BPB H and Svalues, to ensure that the motherboard BIOS and identified by H, S exactly thesame value, which . Otherwise, there have disk error (or simply crash).
2. If you use grldr.mbr, it is still possible situationCHS mismatch occurs, it is because, grub4dos 'automatic detection ofCHS' function does not guarantee 100% success. Really can guarantee 100%success is fbinst. Since CHS There may not be accurate, then this will be dueto a result of the instruction execution INT13 disk error (or simply crash).
Under 3, at CHS guaranteed to match the motherboard BIOScompletely correct the situation, if the GRLDR placed rearward position, beyondthe ability to access the motherboard BIOS int13, in which case there will bedisk error (or simply crash).
4, in the motherboard BIOS supports LBA mode, this is thefirst three are similar. That is, if the GRLDR placed rearward position, beyondthe ability to access the motherboard BIOS int13, in which case there will bedisk error (or simply crash).
If I am not mistaken, this 4 above, if that is the startof all the possibilities for failure.
So, if you want your common U disk, (currently) the onlysoftware you can use is fbinst. If you do not consider the general question,then you can set your own BPB, H and S (matching your motherboard BIOS) to makeyour machine successfully started.
1, parsing the 'File Manager' batch script
This example code reference smine users:
http://bbs.wuyou.net/forum.php?mod=viewthread&tid=203607
smine spent two script files FileList and OpenFile, I am here to merge into a script file FileList.
Usage: The following script (content between +++++) saved as FileList file (UTF-8 format, stored in the default path for external commands),
and then at the command line or FileList FileList /DirPath /can.
Fixes some BUG, adds some usage:
FileList (ud)/
FileList (ud)
FileList /grldr
FileList grldr
FileList g
FileList /Boot/
FileList B
FileList /
FileList
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
! BAT
# Enable redundant mode, the ability to capture the error message
debug on
# Detection Grub4Dos version
checkrange 20110918:!-1 read 0x8278 > nul echo Please use grub4dos-0.4.5b-2011-09-18 or above && exit 1
# Load this module, easy call
delmod -l FileList > nul insmod %0 FileList > nul
# Used to save 'file list' profile
set CfgList=(md)0x60000+0x100
# Used to hold 'open' configuration file
set CfgOpen=(md)0x60100+0x100
# Used to store temporary data
set TmpFile=(md)0x60500+0x100
#Path To list
set FL_Param=%~f1
# Separate directory and file name
set FL_Path=%~dp1
set FL_File=%~nx1
# Enable page display mode (debug 3 debugging)
pager on
# Search for files and directories takes time, here are tips
clear
echo -e is entering the directory: %FL_Path% ..
# Call the sub-processes: Create a 'file list' configuration file
call :GreateCfgList
# Call the sub-processes: create 'open' configuration file
call :GreateCfgOpen
# Execution profile
configfile %CfgList%
#End script
exit
#
# Create a 'file list' configuration file
:GreateCfgList
# Call the sub-processes: initialization profile
call :InitCfgList
# Call the sub-processes: Create a 'title' menu item
call :TitleMenu
# Call the sub-processes: Create a 'return to a' menu item
call :UpMenu
# Call the sub-processes: Create a 'drive or file list' menu item
if exist FL_Path && call :ListFile ! call :ListDrive
exit
# Initial configuration file
:InitCfgList
echo debug off > %CfgList%
echo default 1 >> %CfgList%
echo timeout 60 >> %CfgList%
# Add a blank line
echo >> %CfgList%
exit
# Create a 'title' menu item
: TitleMenu
# Write a menu item (title) to the configuration file (there may be an escape character FL_Path in)
if exist FL_Path && echo -e title in the current directory: %FL_Path% >> %CfgList% ! echo title drive list: >> %CfgList%
# Menu commands: to re-enter the current directory
echo command FileList %FL_Param% >> %CfgList%
# Add a blank line
Echo >> %CfgList%
exit
# Create a 'return to a' menu item
: UpMenu
# Write to the configuration file of a menu item (return to previous)
echo title [.] >> %CfgList%
# For the list of disks, the return on a return to the main menu is (configfile to be on a separate line, otherwise there is no start-sensitive menu command, not up and down to select)
if not exist FL_Path echo -e write 0x307FF8 1 rnconfigfile >> %CfgList% && exit
# For the file or directory, it must obtain the name of the parent directory
call :GetUpDir %FL_Path%
# Build menu command (on a return)
echo command FileList %FL_UpDir% >> %CfgList%
exit
# According to the parameters to obtain the parent directory, the result is stored in the variable FL_UpDir
: GetUpDir
# If the path is only a backslash, you deal directly with
if '%1' '/' && set FL_UpDir= && goto GU_Clear
# The path to be processed is stored %TmpFile%, in order to deal
echo -n %1 > %TmpFile%
# Get the last slash in the path location (LastS: LastSlash)
set LastS=-1 && cat --locate=/ %TmpFile% > nul &; set /a LastS=%?%> nul
# If the path is not a slash, then deal directly
if %LastS% - 1 && set FL_UpDir=&& goto GU_Clear
# Get the path location of the last character (LastC: LastChar)
set LastC=-1 && cat --locate=x00 --number=1 %TmpFile% > nul &; set /a LastC=%?%- 1 > nul
# If a slash at the end, then remove the last slash
if %LastS%%LastC% && cat --length=%LastS% %TmpFile% > %TmpFile%
# Get the last slash in the path location
set LastS=-1 && cat --locate=/ %TmpFile% > nul &; set /a LastS=%?% > nul
# Delete content after the last slash, access path to the parent directory
if not %LastS%-1 set /a LastS=%LastS% + 1 > nul
! if %LastS%-1 && set FL_UpDir=cat --length=%LastS%% TmpFile% set FL_UpDir=
# Clean up temporary data
:GU_Clear
set LastC=
set LastS=
exit
# Create a list of disks
:ListDrive
# List the list of disks (under debug off state, find the disk list command can not be listed)
debug on
find --ignore-floppies > %TmpFile%
# Disk space-separated list
cat --locate=r --replace=x20 %TmpFile% > nul
cat --locate=n --replace=x20 %TmpFile% > nul
# Build menu, according to the list of disks (from the command-line parsing function to handle the extra spaces)
cat %TmpFile% call :ProcessDrive
exit
# Generate a disk menu
:ProcessDrive
# Get the name of the disk you want to generate the menu
set CurDrv=%1
# Discard the first argument to a parameter when processing the next cycle under
shift
# Parameter processing is completed, exit the loop
if not exist CurDrv goto :PDR_Clear
# Determine whether the disk name in parentheses
if not '%CurDrv:~,1%' '(' && goto :ProcessDrives
if not '%CurDrv:~-1%' ')' && goto :ProcessDrives
# Write the menu title
echo title %CurDrv% >> %CfgList%
# Write the menu command
echo command FileList %CurDrv%/ >> %CfgList%
# Write a blank line
echo >> %CfgList%
# Continue to cycle
goto :ProcessDrive
# Clean up temporary data
:PDR_Clear
set CurDrv=
exit
# Create a directory and file list (catalog columns in front, files are listed in the post)
:ListFile
# Clear %TmpFile%, ready to write the file name circulating
echo -n > %TmpFile%
# List files and directories in the current directory, and the directory in which the processing section, part of the file will be saved in %TmpFile%
ls %FL_Param% > nul && ls %FL_Param% call :ProcessDir
# Handle file section
cat %TmpFile% call :ProcessFile
exit
# Create a directory menu
:ProcessDir
# Get the current filename
set CurFile=%1
# Discard the first argument to a parameter when processing the next cycle under
shift
# Parameter processing is completed, exit the loop
if not exist CurFile goto :PD_Clear
# Get the absolute path to the file
set FullPath=%FL_Path%%%CurFile%
# If the file type is a file, not a directory, go to :The Executive Office PD_MarkFile
cat --length=0 %FullPath% > nul && goto :PD_MarkFile
# Write the menu title
echo title [%CurFile%] >> %CfgList%
# Write the menu command
echo command FileList %FullPath%/ >> %CfgList%
# Write a blank line
echo >> %CfgList%
# Continue to cycle
goto :ProcessDir
# Note of the file name, so that the code behind to continue processing
:PD_MarkFile
# The file name is written %TmpFile% in
echo -e x20 >> %TmpFile%
echo %CurFile% >> %TmpFile%
# Continue to cycle
goto :ProcessDir
# Clean up temporary data
:PD_Clear
set CurFile=
set FullPath=
exit
# Generate a file menu
:ProcessFile
# Get the current filename
set CurFile=%1
# Discard the first argument to a parameter when processing the next cycle under
shift
# Parameter processing is completed, exit the loop
if not exist CurFile goto :PF_Clear
# Get the absolute path to the file
set FullPath=%FL_Path%%%CurFile%
# Write the menu title
echo title %CurFile% >> %CfgList%
# Write the menu command
echo set FL_Open=%FullPath% >> %CfgList%
echo configfile %CfgOpen% >> %CfgList%
# Write a blank line
echo >> %CfgList%
# Continue to cycle
goto :ProcessFile
# Clean up temporary data
:PF_Clear
set CurFile=
set FullPath=
exit
#
# Create the 'Open' configuration file
:GreateCfgOpen
# Call the sub-processes :initialization profile
call :InitCfgOpen
# Call the sub-processes :Creating the 'Open' menu item
call :CreateOpenMenu
exit
# Initialize 'open' configuration file
:InitCfgOpen
echo debug off > %CfgOpen%
echo default 0 >> %CfgOpen%
echo timeout 60 >> %CfgOpen%
# Add a blank line
echo >> %CfgOpen%
exit
# Generate the 'Open' menu item
:CreateOpenMenu
echo title to load the disc image and start >> %CfgOpen%
echo echo -e Loading :%FL_Open^% .. >> %CfgOpen%
echo map %FL_Open^% (0xff) >> %CfgOpen%
echo map --hook >> %CfgOpen%
echo chainloader (0xff) >> %CfgOpen%
echo >> %CfgOpen%
echo title loaded disc image into memory and start >> %CfgOpen%
echo echo -e Loading :%FL_Open^% .. >> %CfgOpen%
echo map --mem %FL_Open^% (0xff) >> %CfgOpen%
echo map --hook >> %CfgOpen%
echo chainloader (0xff) >> %CfgOpen%
echo >> %CfgOpen%
# Blank line
echo -e title x20 >> %CfgOpen%
echo clear >> %CfgOpen%
echo >> %CfgOpen%
# Floppy disk load must (fd0), or may fail to start
echo title and start loading the floppy image >> %CfgOpen%
echo echo -e Loading :%FL_Open^% .. >> %CfgOpen%
echo map %FL_Open^% (fd0) >> %CfgOpen%
echo map --hook >> %CfgOpen%
echo rootnoverify (fd0) >> %CfgOpen%
echo chainloader (fd0)+1 >> %CfgOpen%
echo >> %CfgOpen%
# Floppy disk load must (fd0), or may fail to start
echo title floppy image is loaded into memory and start >> %CfgOpen%
echo echo -e Loading :%FL_Open^% .. >> %CfgOpen%
echo map --mem %FL_Open^% (fd0) >> %CfgOpen%
echo map --hook >> %CfgOpen%
echo rootnoverify (fd0) >> %CfgOpen%
echo chainloader (fd0)+1 >> %CfgOpen%
echo >> %CfgOpen%
# Blank line
echo -e title x20 >> %CfgOpen%
echo clear >> %CfgOpen%
echo >> %CfgOpen%
echo title to load disk image and start >> %CfgOpen%
echo echo -e Loading :%FL_Open^% .. >> %CfgOpen%
echo map %FL_Open^% (hd0) >> %CfgOpen%
echo map --hook >> %CfgOpen%
echo rootnoverify (hd0) >> %CfgOpen%
echo chainloader (hd0)+1 >> %CfgOpen%
echo >> %CfgOpen%
echo title disk image is loaded into memory and start >> %CfgOpen%
echo echo -e Loading :%FL_Open^% .. >> %CfgOpen%
echo map --mem %FL_Open^% (hd0) >> %CfgOpen%
echo map --hook >> %CfgOpen%
echo rootnoverify (hd0) >> %CfgOpen%
echo chainloader (hd0)+1 >> %CfgOpen%
echo >> %CfgOpen%
# Blank line
echo -e title x20 >> %CfgOpen%
echo clear >> %CfgOpen%
echo >> %CfgOpen%
echo title as a boot file to start >> %CfgOpen%
echo chainloader %FL_Open^% >> %CfgOpen%
echo >> %CfgOpen%
echo title as a menu file to start >> %CfgOpen%
echo configfile %FL_Open^% >> %CfgOpen%
echo >> %CfgOpen%
echo title as an external command to start >> %CfgOpen%
echo command %FL_Open^% >> %CfgOpen%
echo >> %CfgOpen%
# Blank line
echo -e title x20 >> %CfgOpen%
echo clear >> %CfgOpen%
echo >> %CfgOpen%
echo title to view the file contents (text) >> %CfgOpen%
echo pager on >> %CfgOpen%
echo cat %FL_Open^% >> %CfgOpen%
echo pause >> %CfgOpen%
echo command FileList %FL_Param^% >> %CfgOpen%
echo >> %CfgOpen%
echo title to view the file contents (Hex) >> %CfgOpen%
echo pager on >> %CfgOpen%
echo cat --hex %FL_Open^% >> %CfgOpen%
echo pause >> %CfgOpen%
echo command FileList %FL_Param^% >> %CfgOpen%
echo >> %CfgOpen%
# Blank line
echo -e title x20 >> %CfgOpen%
echo clear >> %CfgOpen%
echo >> %CfgOpen%
echo title as the font file to load (UniFont) >> %CfgOpen%
echo echo -e Loading font files:%FL_Open^%.. >> %CfgOpen%
echo font %FL_Open^%>> %CfgOpen%
echo command FileList %FL_Param^% >> %CfgOpen%
echo >> %CfgOpen%
# Blank line
echo -e title x20 >> %CfgOpen%
echo clear >> %CfgOpen%
echo >> %CfgOpen%
echo title Returns >> %CfgOpen%
echo command FileList %FL_Param^% >> %CfgOpen%
echo >> %CfgOpen%
exit
Using Braces (grub4dos 2018-05 and later)
Can use { } in a batch file to group commands.
<space>{<space> and <space>}<space> must be used.
'if {' , 'else {' or 'else if {' can be used at start of a new line (not in middle of line)
{ or } cannot be at start of line
Nested { { } } not supported.
if XY { ... }
else { ... }
if XY { ... }
else if XY { ... }
Can use { } in menus too if !BAT is used (must be on first line of menu)
The !BAT file scope is only for that one menu entry and does not affect any following menu entries.
Variables used after !BAT must use batch file syntax - e.g. echo %a%%%b% instead of echo %a%%b%
title Test the braces
!BAT
if '12'12' {
set a0=0
if '34'12' { set b0=0 ;; set b1=1 }
else if '12'12' { set b2=2 ;; set b3=3 }
else { set b4=4 ;; set b5=5 }
set b9=9
set b
set a1=1 }
else if '12'12' { set a2=2 ;; set a3=3 }
else { set a4=4 ;; set a5=5 }
set a9=9
set a
pause
Nesting allowed but { and } must be on separate lines (cannot have two { or } on same line.
!BAT
if 1212 {
if 3434 echo fred && if 3444 { echo doris ;; echo jim }
}
pause
hotkey utility
The hotkey grub4dos program allows you to set a hotkey for title and iftitle menu entries or for global actions when in the menu system.
Command examples:
hotkey - installs hotkey, displays help + currently registered keys if hotkey was already run
hotkey -h - installs hotkey or displays registered hotkeys but without displaying help text
hotkey -A - The menu item can be selected by pressing the first letter of the menu entry
hotkey -nb - select menu using hotkey (do not run)
hotkey -nc - disable control key
hotkey -u - uninstall
hotkey (hotkey) 'COMMAND' - set hotkey (hotkey) to always run COMMAND when hotkey is pressed
hotkey (hotkey) - unregister (hotkey)
If -A is used, menu hotkeys p, b, c and e must be shifted (e.g. shift+c to get to grub4dos command console from the menu)
Menu example - to set a hotkey for Ctrl+A key, can use ^ or [ ]
title ^Ctrl+A This menu
or
title [ctrl+A] This menu
If hotkey -A was used, then the user can press t to highlight this menu entry, pressing t again would highlight the next menu entry beginning with t (if there is one).
Examples for global hotkeys (key names are not case sensitive):
hotkey [ctrl+a] 'echo fred ;; echo doris'
hotkey [CTRL-R] 'reboot'
# F7 to boot from internal HDD
()/%grub%/hotkey [F7] 'map (hd0) (hd1) && map (hd1) (hd0) && map --hook && chainloader (hd0)+1 && rootnoverify (hd0) && boot' > nul
Recognised keys are non 0x0000 entries in the following table (e.g. ctrl+1 is not supported, but ctrl+2 is supported).
shift+, ctrl+ and alt+ can be prefixed (not case sensitive) - e.g. alt+= (+ can actually be any character as it is ignored - e.g. alt-f or altZf will work for alt+f)
See here for list of scan codes generated by the BIOS.
hotkey recognises these keys:
- unshifted, shift+, ctrl+, alt+, keyname
- {{0x0231, 0x0221, 0x0000, 0x7800}, '1'},
- {{0x0332, 0x0340, 0x0300, 0x7900}, '2'},
- {{0x0433, 0x0423, 0x0000, 0x7a00}, '3'},
- {{0x0534, 0x0524, 0x0000, 0x7b00}, '4'},
- {{0x0635, 0x0625, 0x0000, 0x7c00}, '5'},
- {{0x0736, 0x075e, 0x071e, 0x7d00}, '6'},
- {{0x0837, 0x0826, 0x0000, 0x7e00}, '7'},
- {{0x0938, 0x092a, 0x0000, 0x7f00}, '8'},
- {{0x0a39, 0x0a28, 0x0000, 0x8000}, '9'},
- {{0x0b30, 0x0b29, 0x0000, 0x8100}, '0'},
- {{0x0c2d, 0x0c5f, 0x0c1f, 0x8200}, '-'},
- {{0x0d3d, 0x0d2b, 0x0000, 0x8300}, '='},
- {{0x1071, 0x1051, 0x1011, 0x1000}, 'q'},
- {{0x1177, 0x1157, 0x1117, 0x1100}, 'w'},
- {{0x1265, 0x1245, 0x1205, 0x1200}, 'e'},
- {{0x1372, 0x1352, 0x1312, 0x1300}, 'r'},
- {{0x1474, 0x1454, 0x1414, 0x1400}, 't'},
- {{0x1579, 0x1559, 0x1519, 0x1500}, 'y'},
- {{0x1675, 0x1655, 0x1615, 0x1600}, 'u'},
- {{0x1769, 0x1749, 0x1709, 0x1700}, 'i'},
- {{0x186f, 0x184f, 0x180f, 0x1800}, 'o'},
- {{0x1970, 0x1950, 0x1910, 0x1900}, 'p'},
- {{0x1a5b, 0x1a7b, 0x1a1b, 0x1a00}, '['},
- {{0x1b5d, 0x1b7d, 0x1b1d, 0x1b00}, ']'},
- {{0x1e61, 0x1e41, 0x1e01, 0x1e00}, 'a'},
- {{0x1f73, 0x1f53, 0x1f13, 0x1f00}, 's'},
- {{0x2064, 0x2044, 0x2004, 0x2000}, 'd'},
- {{0x2166, 0x2146, 0x2106, 0x2100}, 'f'},
- {{0x2267, 0x2247, 0x2207, 0x2200}, 'g'},
- {{0x2368, 0x2348, 0x2308, 0x2300}, 'h'},
- {{0x246a, 0x244a, 0x240a, 0x2400}, 'j'},
- {{0x256b, 0x254b, 0x250b, 0x2500}, 'k'},
- {{0x266c, 0x264c, 0x260c, 0x2600}, 'l'},
- {{0x273b, 0x273a, 0x0000, 0x2700}, ';'},
- {{0x2827, 0x2822, 0x0000,0x0000}, ''},
- {{0x2960, 0x297e, 0x0000,0x0000}, '`'},
- {{0x2b5c, 0x2b7c, 0x2b1c, 0x2600}, '}, same as ctrl+L (actually 2800 on some keyboards)
- {{0x2c7a, 0x2c5a, 0x2c1a, 0x2c00}, 'z'},
- {{0x2d78, 0x2d58, 0x2d18, 0x2d00}, 'x'},
- {{0x2e63, 0x2e43, 0x2e03, 0x2e00}, 'c'},
- {{0x2f76, 0x2f56, 0x2f16, 0x2f00}, 'v'},
- {{0x3062, 0x3042, 0x3002, 0x3000}, 'b'},
- {{0x316e, 0x314e, 0x310e, 0x3100}, 'n'},
- {{0x326d, 0x324d, 0x320d, 0x3200}, 'm'},
- {{0x332c, 0x333c, 0x0000, 0x0000}, ','},
- {{0x342e, 0x343e, 0x0000, 0x0000}, '.'},
- {{0x352f, 0x353f, 0x0000, 0x0000}, '/'},
- {{0x3b00, 0x5400, 0x5e00, 0x6800}, 'f1'},
- {{0x3c00, 0x5500, 0x5f00, 0x6900}, 'f2'},
- {{0x3d00, 0x5600, 0x6000, 0x6a00}, 'f3'},
- {{0x3e00, 0x5700, 0x6100, 0x6b00}, 'f4'},
- {{0x3f00, 0x5800, 0x6200, 0x6c00}, 'f5'},
- {{0x4000, 0x5900, 0x6300, 0x6d00}, 'f6'},
- {{0x4100, 0x5a00, 0x6400, 0x6e00}, 'f7'},
- {{0x4200, 0x5b00, 0x6500, 0x6f00}, 'f8'},
- {{0x4300, 0x5c00, 0x6600, 0x7000}, 'f9'},
- {{0x4400, 0x5d00, 0x6700, 0x7100}, 'f10'},
- {{0x5200, 0x5230, 0x9200, 0xa200}, 'ins'},
- {{0x5300, 0x532e, 0x9300, 0xa300}, 'del'},
- {{0x8500, 0x8700, 0x8900, 0x8b00}, 'f11'},
- {{0x8600, 0x8800, 0x8a00, 0x8c00}, 'f12'},