I created this topic to continue the offtopic discussion from http://reboot.pro/to...n-datatraveler/
This way I will be ontopic
I modified my Grub4DOS boot scripts so I can save/load the automatic loading of the internal USB 2.0 driver from 0.46a.
Also I implemented a way to detect if the driver is already enabled, using info found at this page: http://www.rmprepusb...s-and-functions (thank you Steve).
menu.lst:
if not "%MAINRAN%"=="1" call /initialize.g4b.gz default %DefMenu% title ^U USB 2.0 internal driver (U) set /a DefMenu=*0x8276&0xff > nul configfile /usb2load.lst title root title Ultimate BootCD 5.33 set /a DefMenu=*0x8276&0xff > nul set /a NTS=%DefMenu%/10 > nul if not "%NTS%"=="0" set NTS=%DefMenu% if "%NTS%"=="0" set NTS=0%DefMenu% if "%PLOPDRV%"=="False" write --offset=0 (bd)/menucfg %NTS% > nul configfile /ubcd/menus/grub4dos/main.lst title Memtest 5.01 set /a DefMenu=*0x8276&0xff > nul set /a NTS=%DefMenu%/10 > nul if not "%NTS%"=="0" set NTS=%DefMenu% if "%NTS%"=="0" set NTS=0%DefMenu% if "%PLOPDRV%"=="False" write --offset=0 (bd)/menucfg %NTS% > nul map /iso/memtest.img (fd0)||map --mem /iso/memtest.img (fd0) map --hook chainloader (fd0)+1 rootnoverify (fd0) map --floppies=1 title Paragon Backup & Recovery CD set /a DefMenu=*0x8276&0xff > nul set /a NTS=%DefMenu%/10 > nul if not "%NTS%"=="0" set NTS=%DefMenu% if "%NTS%"=="0" set NTS=0%DefMenu% if "%PLOPDRV%"=="False" write --offset=0 (bd)/menucfg %NTS% > nul map /iso/Paragon_BootCD.iso (0xFF)||map --mem /iso/Paragon_BootCD.iso (0xFF) map --hook root (0xFF) chainloader (0xFF) title ^P Paragon Backup & Recovery CD 2nd way (P) set /a DefMenu=*0x8276&0xff > nul set /a NTS=%DefMenu%/10 > nul if not "%NTS%"=="0" set NTS=%DefMenu% if "%NTS%"=="0" set NTS=0%DefMenu% if "%PLOPDRV%"=="False" write --offset=0 (bd)/menucfg %NTS% > nul map /iso/Paragon_BootCD.iso (0xFF)||map --mem /iso/Paragon_BootCD.iso (0xFF) map --hook root (0xff) kernel /VMLINUZP vga=0x314 initrd /INITRD.GZ title ^M MiniTool Partition Wizard (M) set /a DefMenu=*0x8276&0xff > nul set /a NTS=%DefMenu%/10 > nul if not "%NTS%"=="0" set NTS=%DefMenu% if "%NTS%"=="0" set NTS=0%DefMenu% if "%PLOPDRV%"=="False" write --offset=0 (bd)/menucfg %NTS% > nul map /iso/MiniTool_Partition_Wizard.iso (0xFF)||map --mem /iso/MiniTool_Partition_Wizard.iso (0xFF) map --hook root (0xFF) chainloader (0xFF) title gparted 0.20.0 live set /a DefMenu=*0x8276&0xff > nul set /a NTS=%DefMenu%/10 > nul if not "%NTS%"=="0" set NTS=%DefMenu% if "%NTS%"=="0" set NTS=0%DefMenu% if "%PLOPDRV%"=="False" write --offset=0 (bd)/menucfg %NTS% > nul map /iso/gparted-live-0.20.0-2-i486.iso (0xff) || map --mem /iso/gparted-live-0.20.0-2-i486.iso (0xff) map --hook root (0xff) kernel /live/vmlinuz boot=live config union=aufs noswap noprompt vga=788 ip=frommedia findiso=/iso/gparted-live-0.20.0-2-i486.iso toram=filesystem.squashfs initrd /live/initrd.img title Parted Magic set /a DefMenu=*0x8276&0xff > nul set /a NTS=%DefMenu%/10 > nul if not "%NTS%"=="0" set NTS=%DefMenu% if "%NTS%"=="0" set NTS=0%DefMenu% if "%PLOPDRV%"=="False" write --offset=0 (bd)/menucfg %NTS% > nul map /iso/pmagic_2014_09_29.iso (0xff) || map --mem /iso/pmagic_2014_09_29.iso (0xff) map --hook root (0xff) kernel /pmagic/bzImage edd=off load_ramdisk=1 prompt_ramdisk=0 rw vga=normal sleep=10 loglevel=0 max_loop=256 vmalloc=384MiB keymap=us iso_filename=/iso/pmagic_2014_09_29.iso initrd /pmagic/initrd.img title PartitionGuru 462 FreeDOS set /a DefMenu=*0x8276&0xff > nul set /a NTS=%DefMenu%/10 > nul if not "%NTS%"=="0" set NTS=%DefMenu% if "%NTS%"=="0" set NTS=0%DefMenu% if "%PLOPDRV%"=="False" write --offset=0 (bd)/menucfg %NTS% > nul map --mem /iso/PartitionGuru462FreeDOS.img.gz (fd0) map --hook root (fd0) chainloader /kernel.sys title SystemRescueCd set /a DefMenu=*0x8276&0xff > nul set /a NTS=%DefMenu%/10 > nul if not "%NTS%"=="0" set NTS=%DefMenu% if "%NTS%"=="0" set NTS=0%DefMenu% if "%PLOPDRV%"=="False" write --offset=0 (bd)/menucfg %NTS% > nul kernel /sysrcd/rescue32 subdir=sysrcd setkmap=us initrd /sysrcd/initram.igz title root title Knoppix LiveCD set /a DefMenu=*0x8276&0xff > nul set /a NTS=%DefMenu%/10 > nul if not "%NTS%"=="0" set NTS=%DefMenu% if "%NTS%"=="0" set NTS=0%DefMenu% if "%PLOPDRV%"=="False" write --offset=0 (bd)/menucfg %NTS% > nul configfile /KNOPPIX/knoppix.lst title ^F Start installed Fedora 18 on USB drive (F) set /a DefMenu=*0x8276&0xff > nul set /a NTS=%DefMenu%/10 > nul if not "%NTS%"=="0" set NTS=%DefMenu% if "%NTS%"=="0" set NTS=0%DefMenu% if "%PLOPDRV%"=="False" write --offset=0 (bd)/menucfg %NTS% > nul kernel (hd0,1)/boot/vmlinuz-3.9.9-201.fc18.i686 root=UUID=5831c69e-e9fd-4f61-812a-ebb9207c1155 rd.md=0 rd.lvm=0 rd.dm=0 rd.luks=0 rhgb quiet vga=791 initrd (hd0,1)/boot/initramfs-3.9.9-201.fc18.i686.img title Switch to GRUB2 core.img for booting Linux (Ubuntu, Fedora etc) set /a DefMenu=*0x8276&0xff > nul set /a NTS=%DefMenu%/10 > nul if not "%NTS%"=="0" set NTS=%DefMenu% if "%NTS%"=="0" set NTS=0%DefMenu% if "%PLOPDRV%"=="False" write --offset=0 (bd)/menucfg %NTS% > nul clear echo Please wait, searching for GRUB2 core img... set IMGF=0 find --set-root --ignore-floppies --ignore-cd /boot/grub2/i386-pc/core.img > nul && set IMGF=1 && kernel /boot/grub2/i386-pc/core.img && boot if "%IMGF%"=="0" find --set-root --ignore-floppies --ignore-cd /boot/grub/i386-pc/core.img > nul && set IMGF=1 && kernel /boot/grub/i386-pc/core.img && boot if "%IMGF%"=="0" clear && echo GRUB2 core img not found! Returning to main menu... && pause --wait=5 configfile title root title Start an antivirus rescue disk set /a DefMenu=*0x8276&0xff > nul set /a NTS=%DefMenu%/10 > nul if not "%NTS%"=="0" set NTS=%DefMenu% if "%NTS%"=="0" set NTS=0%DefMenu% if "%PLOPDRV%"=="False" write --offset=0 (bd)/menucfg %NTS% > nul configfile /antivirus.lst title root title ^B Find bootable Windows NT/2000/XP/Vista/7/8 partitions (B) set /a DefMenu=*0x8276&0xff > nul set /a NTS=%DefMenu%/10 > nul if not "%NTS%"=="0" set NTS=%DefMenu% if "%NTS%"=="0" set NTS=0%DefMenu% if "%PLOPDRV%"=="False" write --offset=0 (bd)/menucfg %NTS% > nul call /findbwin.g4b.gz configfile title root title Windows XP SP3 x86 setup map --unmap=0:0xff map --unhook && map --rehook set /a DefMenu=*0x8276&0xff > nul set /a NTS=%DefMenu%/10 > nul if not "%NTS%"=="0" set NTS=%DefMenu% if "%NTS%"=="0" set NTS=0%DefMenu% if "%PLOPDRV%"=="False" write --offset=0 (bd)/menucfg %NTS% > nul ls /usbdrive.tag > nul || find --set-root --devices=hf /usbdrive.tag configfile /winxpsetup.lst title Windows 7 SP1 setup map --unmap=0:0xff map --unhook && map --rehook set /a DefMenu=*0x8276&0xff > nul set /a NTS=%DefMenu%/10 > nul if not "%NTS%"=="0" set NTS=%DefMenu% if "%NTS%"=="0" set NTS=0%DefMenu% if "%PLOPDRV%"=="False" write --offset=0 (bd)/menucfg %NTS% > nul ls /usbdrive.tag > nul || find --set-root --devices=hf /usbdrive.tag configfile /win7setup.lst title root title ^S Shutdown (S) halt title ^R Reboot (R) reboot
initialize.g4b:
!BAT timeout 30 && /hotkey > nul color black/cyan yellow/cyan > nul set PLOPDRV=False && cat --hex --locate="PoLPu@" --number=1 (md)0x3d0+0x130 > nul && set PLOPDRV=True set USB2DRV=False set /a USBDRN=*0x8351 & 0xff > nul if not "%USBDRN%"=="0" set USB2DRV=True set LDUSBDRV=False set MAINRAN=1 && graphicsmode -1 640:800 480:600 24:32 > nul cat --length=3 --skip=0 --number=1 /menucfg | set NTS= set /a DefMenu=10*%NTS:~0,1%+%NTS:~1,1% > nul if not "%NTS:~2,1%"=="1" goto :end set LDUSBDRV=True if "%USB2DRV%"=="False" usb --init set /a USBDRN=*0x8351 & 0xff > nul if not "%USBDRN%"=="0" set USB2DRV=True :end
usb2load.lst:
timeout 30 default 2 set /a NTS=%DefMenu%/10 > nul if not "%NTS%"=="0" set NTS=%DefMenu% > nul if "%NTS%"=="0" set NTS=0%DefMenu% > nul title ...Back to Main Menu write --offset=0 (bd)/menucfg %NTS% > nul configfile /menu.lst title root iftitle [if "%LDUSBDRV%"=="False"] Enable USB 2.0 internal driver automatic loading all sessions clear write --offset=0 (bd)/menucfg %NTS%1 > nul if "%USB2DRV%"=="True" set LDUSBDRV=True && echo -e USB 2.0 internal driver automatic loading enabled if "%USB2DRV%"=="False" usb --init && set /a USBDRN=*0x8351 & 0xff > nul ;; if "%USB2DRV%"=="False" if not "%USBDRN%"=="0" set USB2DRV=True && set LDUSBDRV=True && echo -e \r\nUSB 2.0 internal driver automatic loading enabled echo -e Returning to main menu... pause --wait=5 configfile /menu.lst iftitle [if "%LDUSBDRV%"=="True"] Disable USB 2.0 internal driver automatic loading all sessions clear write --offset=0 (bd)/menucfg %NTS%0 > nul set LDUSBDRV=False > nul && echo -e USB 2.0 internal driver automatic loading disabled\r\nReturning to main menu... pause --wait=5 configfile /menu.lst iftitle [if "%USB2DRV%"=="False"] Just enable USB 2.0 internal driver this session clear usb --init set /a USBDRN=*0x8351 & 0xff > nul if not "%USBDRN%"=="0" set USB2DRV=True echo -e \r\nReturning to main menu... pause --wait=5 configfile /menu.lst
Btw, here I used the slow iftitle's because I rarely use this menu (it's loading the USB driver automatically).
The rest of the files: Files.7z 7.59KB 435 downloads
1. As you can see, in menu.lst I'm not using the savedefault function anymore. I made some custom code:
set /a DefMenu=*0x8276&0xff > nul set /a NTS=%DefMenu%/10 > nul if not "%NTS%"=="0" set NTS=%DefMenu% if "%NTS%"=="0" set NTS=0%DefMenu% if "%PLOPDRV%"=="False" write --offset=0 (bd)/menucfg %NTS% > nul
In the same file (menucdfg) I save 0/1 in the third position to enable/disable the automatic loading of the USB 2.0 internal driver.
If DefMenu is in 0..9, a '0' is added in front so it would always be saved as 2 chars.
Question: is there a simpler way to do this?
2. The USB 2.0 internal driver detection code:
set USB2DRV=False set /a USBDRN=*0x8351 & 0xff > nul if not "%USBDRN%"=="0" set USB2DRV=True
Seems to work fine.
But there is a problem: if Grub4DOS is reloaded without restarting the computer, the USB 2.0 driver is still active but this code sets USB2DRV to False.
Is there a way to modify the code to work fine in this situation too?
3. The code for loading configuration from menucfg:
set LDUSBDRV=False cat --length=3 --skip=0 --number=1 /menucfg | set NTS= set /a DefMenu=10*%NTS:~0,1%+%NTS:~1,1% > nul if not "%NTS:~2,1%"=="1" goto :end set LDUSBDRV=True if "%USB2DRV%"=="False" usb --init set /a USBDRN=*0x8351 & 0xff > nul if not "%USBDRN%"=="0" set USB2DRV=True :end
Notice the use of "cat" command to read from file into the variable. But this command is slow (about 1 sec on my computer). dd command is a lot faster but when I tried to read from the memory location into the variable it didn't do anything.
Is there a way to use only dd without cat?
Thank you.
Regards,
David