Jump to content











Photo

In need of help with grub4dos command


  • Please log in to reply
21 replies to this topic

#1 painsage

painsage

    Newbie

  • Members
  • 10 posts
  •  
    Yugoslavia

Posted 2 weeks ago

Hello,i just started using grub4dos on my usb for booting... So today i put a splashart in my menu.ist file,and i wanted to set when i press f5 to restart the computer,and f6 for shutdown.. So i saw online,and downloaded the hotkey file needed to set it up,i put this in my menu .ist file:

title ^F5 Restart
restart
 
title ^F6 Shutdown
halt
So now,i want the commands to still work,but i dont want these titles to be visible in the boot menu..(You cant select them,you cant see them,and you cant start them...)
Any help is appreciated...
Thanks
 
 


#2 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 14919 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 2 weeks ago

So you want a couple hidden menu entries, actionable by the hotkeys.

 

It should be enough to remove the text following the hotkey, i.e.:

title ^F6 Shutdown
halt

becoming:

title ^F6
#Shutdown
halt

But see also here:

https://www.rmprepus...orials/grub4dos

 

"Secret menus".

 

:duff:

Wonko



#3 painsage

painsage

    Newbie

  • Members
  • 10 posts
  •  
    Yugoslavia

Posted 2 weeks ago

Yeah,i tried that,you can still select it in the menu,it just has no name... I want the hotkey to work,but so that you cant select the title in the menu..



#4 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 14919 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 2 weeks ago

Yep :), hence I pointed you also to a more complex solution (which BTW may or may not work as you wish), is "that" the "that" that you already tested unsuccessfully?

 

Maybe (only thinking out loud) it is possible to check if last key pressed was a function key and only execute the menu entry if that is true :unsure:, see Fn20 here:

https://www.rmprepus...s-and-functions

 

 

20 checkkey- get kbd key without emptying buffer - e.g. call Fn.20 ;; set /A key=%@retval%&0xff > nul ;; echo %key% prints 0x31 if number 1 key pressed (top 8 bits is scancode, bottom 8 are ASCII code, Function keys are 'special') @retval returns -1 if no key available.

 

So the entry will be hidden, selectable, but will do nothing unless it was triggered by the Functon key :dubbio:.

 

:duff:

Wonko



#5 painsage

painsage

    Newbie

  • Members
  • 10 posts
  •  
    Yugoslavia

Posted 2 weeks ago

Hello,i want the entry to be hidden,but not selectable,but i want the hotkey to still work.. Since im not sure if theres a command that would allow this,is there any other way to make hotkeys work,without setting up an entry?
Thank you so much for you help,Wonko!

#6 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 14919 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 2 weeks ago

Hello,i want the entry to be hidden,but not selectable,but i want the hotkey to still work.. Since im not sure if theres a command that would allow this,is there any other way to make hotkeys work,without setting up an entry?
Thank you so much for you help,Wonko!

I have no idea if the above Fn20 idea works, it may, but unless you test it we'll never know.

 

A selectable (but doing nothing when selected) blank line (working fine with Function key ONLY) seems to me a good enough approximation (again IF it works).

 

DavidB made something similar (using the 0x8276 value instead), see here:

http://reboot.pro/to...n-with-hotkeys/

 

His initial approach is simple enough, but with the attached string of "fixed menu.lst entry numbers" and when it comes to auto-determine based on menu.lst entry numbers it becomes fairly complex, if the Fn20 approach works it might become easier/straightforward.

 

Let's wait a bit, if Steve6375 or tinybit may happen to see this thread and have an idea (or have already a solution)

 

:duff:

Wonko



#7 painsage

painsage

    Newbie

  • Members
  • 10 posts
  •  
    Yugoslavia

Posted 2 weeks ago

I hope that Steve or tinybit know how to solve this... I want to set it up like you have in gfxmenu,you press f9 to reboot.. .I want to do something like that,but without gfxmenu,and since i saw the entry approach to this,i thought i'd give it a shot... And it does work,the only problem is,that its selectable (it is not hidden),and that really irritates me...

Thanks for your help,i guess i'll wait for Steve or tinybit



#8 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 14919 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 2 weeks ago

Wait a minute.

 

Rethinking about it, you need only "simple commands", not really "menu entries".

 

 

Apr 8 2015 Hotkey for grub4dos by chenall
Usage:

hotkey -nb only selected menu when press menu hotkey
hotkey -nc disable control key
hotkey -A Select the menu item with the first letter of the menu
hotkey [HOTKEY] "COMMAND" register new hotkey
e.g.
hotkey [F9] "reboot"
hotkey [HOTKEY] Disable Registered hotkey HOTKEY

Command keys such as p, b, c and e will only work if SHIFT is pressed when hotkey -A

 

You can do the following:

hotkey

hotkey [F5] "restart"

hotkey [F6] "halt"

 

This way there won't be any menu.lst entries (so they won't be visible nor selectable, let alone executable), but if you press F5 or F6 the corresponding command will be executed.

 

:duff:

Wonko


  • ReTokener likes this

#9 painsage

painsage

    Newbie

  • Members
  • 10 posts
  •  
    Yugoslavia

Posted 2 weeks ago

Wonko you are my hero... It worked... I dont know how i missed that line in the tutorial.... 

But now im struggling to understand how the numbering entries in the menu works...

I cant get the numbers to be right (for my entries) it starts with 0,1,2,3,4-and i dont know how to change it to start with 1-so 1,2,3,4.. Is it possible to do this without adding like Steve's menu... (i saw this in the tutorial).. As far as i understood the statement "Steve's menu" is being counted like 0,even tho you cant select or access it,so the next entry is selectable,so it starts with 1?

Thanks for your help



#10 steve6375

steve6375

    Platinum Member

  • Developer
  • 7033 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars, www.easy2boot.com
  •  
    United Kingdom

Posted 2 weeks ago

The first menu entry is always 0.

If you want to start from 1 then use a blank menu entry for the first menu entry

 

notice the space after the word title...

title \n
root

title menu number 1
etc.


#11 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 14919 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 2 weeks ago

Wonko you are my hero... It worked... I dont know how i missed that line in the tutorial....

Basically because it is seemingly not there :w00t:, the feature must have been added later and AFAICT noone documented or mentioned it.
 
I only found it by chance, reading the "Usage;" I quoted.
 
The "new" version has been posted by Steve6375 underlining the -A usage but not the other "direct assigning" of commands:
http://reboot.pro/to...4dos/?hl=hotkey
on the site the "Usage:" must be of an earlier version:
https://www.rmprepus...ey-menu-entries
and later edited only for the -A added option
 
From the mouth of the wolf ;) (you'd better use the google translate link):
https://grub4dos.che...t/utils/hotkey/
https://translate.go...t/utils/hotkey/

 

Please note the (optional) usage of @ to hide the commands:

 

 

2013-10-14 Added support hotkey command, which can specify a hotkey for some commands, and execute when the hotkey is pressed

grammar
Hotkey [ HOTKEY ] "COMMAND"
Example: After using the following command, if you press F9, it will execute reboot.
Hotkey [ F9 ] reboot
Support for multiple commands at the same time""
Hotkey [ A ] "echo Is test ;; pause test"
You can use the hidden mode to hold the button in front of the command without any screen display.
Hotkey [ F2 ] "@kernel /xxxx ;; initred /xxxx ;; boot"
Use the hotkey without command to remove or disable the hotkey. For example: Disable registered F9 hotkeys
Hotkey [ F9 ]
Note: Two hotkey modes can be selected as needed.

 
Very likely what happened was that Steve made his page after first release 2011-12-30 and only updated it when the 2015-04-08 came out, somehow missing the update related to the 2013-10-14 version.

Anyway, all is well that ends well.  :)

 

:duff:

Wonko



#12 painsage

painsage

    Newbie

  • Members
  • 10 posts
  •  
    Yugoslavia

Posted 2 weeks ago

@Steve i tried that... I tried naming it my menu,just to check if its there,and even tho the first entry is my menu with root(),it still starts with 0(the next entry is still 0)

Here is my command

 

title my menu
root()


#13 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 14919 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 2 weeks ago

Try this one (save it as - say - numbers.lst and invoke it from command prompt as configfile /numbers.lst )

color black/cyan yellow/cyan
timeout 30

title This is 0
set /a CURDEF=*0x8276 & 0xff > nul
echo grub4dos sees this as menu entry #%CURDEF%
pause

title this is 1
set /a CURDEF=*0x8276 & 0xff > nul
echo grub4dos sees this as menu entry #%CURDEF%
pause

title and this is 2
set /a CURDEF=*0x8276 & 0xff > nul
echo grub4dos sees this as menu entry #%CURDEF%
pause

:duff:

Wonko



#14 steve6375

steve6375

    Platinum Member

  • Developer
  • 7033 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars, www.easy2boot.com
  •  
    United Kingdom

Posted 2 weeks ago

The first menu entry in your menu should be

title \n
root

EXACTLY THIS - do not add anything!

 

You should see that you grub4dos menu will now have a blank line as menu entry 0

If you set the default as 1, then your first menu entry that follows this menu entry will be highlighted which will be menu entry 1.

 

Are you using --auto-num-on too?

If so use this:

default 1
/_ISO/e2b/grub/hotkey -A
setmenu --auto-num-on

title \n
errorcheck off
boot

title my menu
.....

You will see the attached screen.

 

Is that what you wanted?

 

 

 

 

 

Attached Files



#15 painsage

painsage

    Newbie

  • Members
  • 10 posts
  •  
    Yugoslavia

Posted 2 weeks ago

@Wonko Im not looking for anything complex,im thinking about Steve's idea? I think it would be simpler to just create a blank menu as (0).. But thanks for your idea!

@Steve I tried that,it didnt work,im sending you a screenshot,and my menu.ist file

https://ibb.co/86Bpvhp

My menu.ist file:

 

 

clear
debug off
# autonumber menu entries 0x20 is space character after number, 01 = enable numbering
write --bytes=2 0x8274 0x2001
# set 1920x1080 and load background (don't display 'Loading splashimage...' text by redirecting to nul)
graphicsmode -1 1920 1080 24:32 && splashimage /back.jpg > nul
password iq200
# set colours
color normal=0xC highlight=0xF helptext=0xF heading=0x9 standard=0x8 border=0x8
# Note: apart from highlighted, standard and heading text, any background colour is ignored as it will always be 'transparent'
 
# wordspacing and linespacing normally set to 0, borderwidth=0 for no border, 1 for thin border, etc.
# /menusetting.gz u will restore max menu grub4dos default
set wdspace=0
set lnspace=0
set topstart=5
set rstart=1
set noitems=8
set menuw=75
set bdwidth=0
set tophelp=60
/menusetting.gz u
# place a 10 entry menu at extreme right of 1920x1080 splashimage bitmap, starting 10 lines down
/menusetting.gz %wdspace% %lnspace% %bdwidth% %tophelp% %noitems% %topstart% %menuw% %rstart%
 
 
hotkey [F5] "reboot"
hotkey [F6] "halt"
 
 
## Menu AutoNumber
write 0x8274 0x2001
 
#font /unifont.hex.gz
 
#clear mappings and set root in case we return from bootmgr
map --unmap=0:0xff
map --unhook
map --rehook
ls /usbdrive.tag > nul || find --set-root --devices=hf /usbdrive.tag > nul
ls /default > nul && default /default
 
 
title \n
root
 
title Windows 7 AIO/ Windows 10 x86/x64 Setup /\nLoad All Windows Installers loacted on the USB Drive (Windows 7/Windows 10)\nPress F5 to Reboot\nPress F6 to Shutdown
lock
map --unhook
map --unmap=0:0xff && map --rehook
savedefault +1
ls /shifthd.bat > nul || find --set-root --devices=hf /shifthd.bat
/shifthd.bat
if "%RDSK%"=="" pause Fatal error while swapping hard disk order, cannot continue! && configfile /menu.lst
root (hd%RDSK%,0)
chainloader /BOOTMGR
 
title Boot to Drive\nBoot to the first Configured Boot Device in BIOS\nPress F5 to Reboot\nPress F6 to Shutdown
map --unhook
map --unmap=0:0xff && map --rehook
savedefault
ls /shifthd.bat > nul || find --set-root --devices=hf /shifthd.bat
/shifthd.bat
if "%RDSK%"=="" pause Fatal error while swapping hard disk order, cannot continue! && configfile /menu.lst
pause --wait=1 Booting MBR on hd0 ...
chainloader (hd0)+1
 
title Hirens Boot CD\nBoot to Hirens Boot CD\nPress F5 to Reboot\nPress F6 to Shutdown
lock
map --unmap=0:0xff
map --unhook && map --rehook
cat --hex --locate=PoLPu@ (md)0x3D0+0x130 > nul && echo Cannot continue if PLoP is active, please start this entry without loading PLoP first && echo && pause Press any key to return to the main menu && configfile /menu.lst
set /a dev=*0x8280&0xff
root (%dev%,0)
set ISO=/ISO/HirensBootCD.iso
ls %ISO% > nul || find --set-root --devices=hf /usbdrive.tag|| echo Error! Could not find usbdrive.tag && echo  && pause Press any key to return to the main menu && configfile /menu.lst
ls %ISO% > nul || find --set-root --devices=hf %ISO% || echo Error! Could not find %ISO% && echo  && pause Press any key to return to the main menu && configfile /menu.lst
map %ISO% (0xff) || map --heads=0 --sectors-per-track=0 %ISO% (0xff) || echo FATAL ERROR mapping %ISO%, please check if file is present and defragmented && pause Press any key to return to main menu && configfile /menu.lst
set /a dev=*0x82a0&0xff
debug 1
parttype (%dev%,3) | set check=
debug off
set check=%check:~-5,4%
if "%check%"=="0x00" partnew (%dev%,3) 0 0 0 && partnew (%dev%,3) 0x00 %ISO%
if not "%check%"=="0x00" echo WARNING: PARTITION TABLE 4 IN BIOS DEVICE %dev% IS ALREADY IN USE! && echo  && echo To prevent possible data loss will not continue further && pause && configfile /menu.lst
map --rehook
root (0xff)
chainloader (0xff)
 
title GoldMemory PRO v.7.85\nBoot to GoldMemory PRO v. 7.8.5\nPress F5 to Reboot\nPress F6 to Shutdown
lock
map /ISO/GoldMem.img (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)
map --floppies=1
 
 
Thank you both for your awesome ideas,and for helping me.. Im new to grub4dos...


#16 steve6375

steve6375

    Platinum Member

  • Developer
  • 7033 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars, www.easy2boot.com
  •  
    United Kingdom

Posted 2 weeks ago

You are using autonumbering, so use the menu I just suggested for autonumbering.

#17 painsage

painsage

    Newbie

  • Members
  • 10 posts
  •  
    Yugoslavia

Posted 2 weeks ago

@Steve the problem with that command,while it does work,i can still select the empty entry which is really annoying.. Is there any way to get it working,but without having it selectable?



#18 steve6375

steve6375

    Platinum Member

  • Developer
  • 7033 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars, www.easy2boot.com
  •  
    United Kingdom

Posted 2 weeks ago

I can't think of anything.

 

Using 0x8274 with a value of 01 will number only the bootable menu entries, using 02 will number all menu entries (both bootable and not).

 

But in all cases they all start at 0.

 

What you could do is not use autonumbering and just use numbers in your menu entries, e.g.

 

title 1 This is menu 1

....

 

title 2 This is next menu

...

 

 

I am afraid the whole grub4dos menu system, auto-numbering, menu selection, jumping, defaults, etc, is all 0 based.



#19 painsage

painsage

    Newbie

  • Members
  • 10 posts
  •  
    Yugoslavia

Posted 2 weeks ago

@Steve Okay,but what exactly is autonumbering? And how does it work?

Thanks



#20 steve6375

steve6375

    Platinum Member

  • Developer
  • 7033 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars, www.easy2boot.com
  •  
    United Kingdom

Posted 2 weeks ago

If you read the 3rd and 4th line of your own menu - you will see!

 

P.S. You have autonumbering enabled twice in your menu, the first is correct - uses the space character as a separator (0x20) and 01 as the type of autonumbering (only numbers bootable entries). It should only write 2 bytes.

 

write --bytes=2 0x8274 0x2001

 

The second item further down is incorrect and should be removed. It writes 4 bytes and so corrupts 2 other locations.

write 0x8274 0x2001

 

But actually with the latest grub4dos, you don't need to use the write command at all, just use

 

setmenu --auto-num-on

 

or

 

setmenu --auto-num-off


Edited by steve6375, 2 weeks ago.


#21 painsage

painsage

    Newbie

  • Members
  • 10 posts
  •  
    Yugoslavia

Posted 2 weeks ago

Thanks for helping,i disabled autonumbering,i like it better without the numbers at all..

Thanks for helping me guys!



#22 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 14919 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 2 weeks ago

@Steve the problem with that command,while it does work,i can still select the empty entry which is really annoying.. Is there any way to get it working,but without having it selectable?

 
Hmmm. :dubbio:
 
any of these might do as first entry:
 
 
title \n
fallback 1
echo Hey dumbass this is entry 0, you shouldn't select empty lines, I will boot menu entry 1 instead.
pause
root (NOTHING)
 
or:
title \n
echo Hey mate, why do you think this entry has no text? Let's redo from start ...
pause
write 0x307ff8 1 && configfile
 
or:
title \n
call Fn.0 0 0x8217 | set mymenu=
configfile %mymenu%

 

:duff:

Wonko






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users