Jump to content











Photo
* * * * * 1 votes

Grub4dos Find and boot


  • Please log in to reply
113 replies to this topic

#51 steve6375

steve6375

    Platinum Member

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

Posted 25 May 2013 - 02:57 PM

I am using 2013-04-19

 

The following works fine in a menu

echo fred && pause --wait=10 ;; echo doris ;; pause ;; echo Fini

and this works fine as a batch file

!BAT
echo fred && pause --wait=10 ;; goto :fred
goto :eof
:fred
echo Worked

Chenall has added these commands and several bug fixes into the latest version and it will become a new 'featured' version at some point.

 

P.S. You can now add inline comments by using  echo fred ;; # this echos fred to the console.

 

re. chainloader - I think it only waits for a key because it is the last command and it has failed - so grub4dos prompts before returning you to the menu.

 

why don't you simply write the error message out yourself?

 

chainloader /ddd && boot

echo Chainloader failed!

(do stuff)



#52 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 25 May 2013 - 03:33 PM

I am using 2013-04-19

 

The following works fine in a menu





echo fred && pause --wait=10 ;; echo doris ;; pause ;; echo Fini

and this works fine as a batch file





!BAT
echo fred && pause --wait=10 ;; goto :fred
goto :eof
:fred
echo Worked

Chenall has added these commands and several bug fixes into the latest version and it will become a new 'featured' version at some point.

 

P.S. You can now add inline comments by using  echo fred ;; # this echos fred to the console.

 

 

Nice :D
Well, when it will be "Featured" I will use it and adapt the script for that version...

 

re. chainloader - I think it only waits for a key because it is the last command and it has failed - so grub4dos prompts before returning you to the menu.

 

 

Hmm, I don't know, even if I add other command after /chainloader it waits for a key and doesn't start them (with key or not).

 

why don't you simply write the error message out yourself?

 

chainloader /ddd && boot

echo Chainloader failed!

(do stuff)

 

I knew I can do that but I wanted to keep the grub4dos error message because it could help the user to find/fix the problem more than my standard error message could...



#53 steve6375

steve6375

    Platinum Member

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

Posted 25 May 2013 - 04:12 PM

chainloader /ubu.iso && boot
(do some stuff here??)
echo Chainloader failed - error was at line:
chainloader /ubu.iso


#54 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 25 May 2013 - 05:20 PM

It's a little unusual to call again chainloader knowing that it will not function, but if it's working, it's good. :D
You solved the problem.
Thank you very much.

I updated the script:

 



!BAT
setlocal
clear
echo Please wait, searching...
find --devices=h > (md)0x220+8
set SKIPPED=0
set N=0
set BDN=-1
#########   if the batch was started with /abd as parameter it will not search
#########   on boot device (if it's seen as a HDD). Usually is the USB drive (hd0)
if "%1"=="/abd" if "%?_BOOT:~1,2%"=="hd" set BDN=%?_BOOT:~3,1%
:loop
cat --skip=%SKIPPED% --number=1 --locate=" (hd" (md)0x220+8  | set PPOSB=
if "%PPOSB%"=="" goto endloop
set /a SKIPPED=0x%PPOSB%+7 > nul
cat --skip=%SKIPPED% --number=1 --locate=")" (md)0x220+8  | set PPOSE=
if "%PPOSE%"=="" goto endloop
set /a PPOSL=0x%PPOSE%-0x%PPOSB% > nul
set /a SKIPPED=0x%PPOSB%+1 > nul
cat --skip=%SKIPPED% --length=%PPOSL% --locate=" " (md)0x220+8 && set /a SKIPPED=0x%PPOSB%+7 > nul && goto :loop
cat --skip=%SKIPPED% --length=%PPOSL% --locate="," --number=1 (md)0x220+8 | set CPOS=
if "%CPOS%"=="" set /a SKIPPED=0x%PPOSB%+7 > nul && goto :loop
set /a PNL=0x%PPOSE%-0x%CPOS%-1 > nul
set /a SKIPPED=0x%CPOS%+1 > nul
cat --skip=%SKIPPED% --length=%PNL% (md)0x220+8 | set PN=
set /a HDNL=0x%CPOS%-0x%PPOSB%-4 > nul
set /a SKIPPED=0x%PPOSB%+4 > nul
cat --skip=%SKIPPED% --length=%HDNL% (md)0x220+8 | set HDN=

if %PN%>=4 goto :notgood
if %BDN%==%HDN% goto notgood
checkrange 0x06:0x0e parttype (hd%HDN%,%PN%) > nul || goto :notgood

ls (hd%HDN%,%PN%)/ > (md)0x300+8
cat --locate=\0 --number=1 (md)0x300+8 | set ENDFILE=
set /a ENDFILE=0x%ENDFILE% > nul
if not "%ENDFILE%"=="0" write --offset=%ENDFILE% (md)0x300+8 \ \0 > nul

cat --locate=" ntldr " --number=1 (md)0x300+8 > nul || goto :nont
cat --length=0 (hd%HDN%,%PN%)/ntldr | set NTS=
set /a NTS=0x%NTS:~14% > nul
if %NTS%<=74999 goto notgood
set /a N=%N%+1 > nul
set CLCMD=chainloader
if %NTS%>=218976 set OS=XP && goto :esnt
if %NTS%>=185208 set OS=2000 && goto :esnt
set OS=NT
set CLCMD=chainloader --force --load-segment=0x2000
:esnt
if %HDN%==0 set HDNT=first && set HDNTR=USB drive
if %HDN%==1 set HDNT=second && set HDNTR=first internal HDD
if %HDN%==2 set HDNT=third && set HDNTR=second internal HDD
if %HDN%==3 set HDNT=fourth && set HDNTR=third internal HDD
if %HDN%>=4 set HDNT=%HDN%th && set /a HDNN=%HDN%+1 > nul && set HDNTR=%HDN%th internal HDD
if %HDN%==0 set REMAP=
if %HDN%==0 set AFTERR=
if %HDN%>=1 set REMAP=\r\nmap (hd%HDN%) (hd0)\r\nmap (hd0) (hd%HDN%)\r\nmap --rehook
if %HDN%>=1 set AFTERR=\ \&\& boot\r\nmap (hd%HDN%) (hd0)\r\nmap (hd0) (hd%HDN%)\r\nmap --rehook\r\nroot (bd) \> nul\r\n%CLCMD% (hd%HDN%,%PN%)/ntldr
if %PN%==0 set PNT=first
if %PN%==1 set PNT=second
if %PN%==2 set PNT=third
if %PN%==3 set PNT=fourth


set BWINM%N%=title Boot to Windows %OS% on %HDNT% HDD, %PNT% partition\\nUsually the %HDNTR%...%REMAP%\r\nroot (hd0,%PN%) \> nul\r\%CLCMD% /ntldr%AFTERR%
:nont

cat --locate=" bootmgr " --number=1 (md)0x300+8 > nul || goto :nomgr
cat --length=0 (hd%HDN%,%PN%)/bootmgr | set MGRS=
set /a MGRS=0x%MGRS:~14% > nul
if %MGRS%<=199999 goto notgood
if %MGRS%==438840 set OS=Vista && goto :esmgr
if %MGRS%>=390971 set OS=8 && goto :esmgr
if %MGRS%>=358410 set OS=7 && goto :esmgr
set OS=Vista
:esmgr
set /a N=%N%+1 > nul
if %HDN%==0 set HDNT=first && set HDNTR=USB drive
if %HDN%==1 set HDNT=second && set HDNTR=first internal HDD
if %HDN%==2 set HDNT=third && set HDNTR=second internal HDD
if %HDN%==3 set HDNT=fourth && set HDNTR=third internal HDD
if %HDN%>=4 set HDNT=%HDN%th && set /a HDNN=%HDN%+1 > nul && set HDNTR=%HDN%th internal HDD
if %HDN%==0 set REMAP=
if %HDN%==0 set AFTERR=
if %HDN%>=1 set REMAP=\r\nmap (hd%HDN%) (hd0)\r\nmap (hd0) (hd%HDN%)\r\nmap --rehook
if %HDN%>=1 set AFTERR=\ \&\& boot\r\nmap (hd%HDN%) (hd0)\r\nmap (hd0) (hd%HDN%)\r\nmap --rehook\r\nroot (bd) \> nul\r\nchainloader (hd%HDN%,%PN%)/bootmgr
if %PN%==0 set PNT=first
if %PN%==1 set PNT=second
if %PN%==2 set PNT=third
if %PN%==3 set PNT=fourth

set BWINM%N%=title Boot to Windows %OS% on %HDNT% HDD, %PNT% partition\\nUsually the %HDNTR%...%REMAP%\r\nroot (hd0,%PN%) \> nul\r\nchainloader /bootmgr%AFTERR%
:nomgr

:notgood

set /a SKIPPED=0x%PPOSE%+2 > nul
if %N%>=15 goto :endloop
goto :loop
:endloop
if %N%==0 endlocal && clear && echo No bootable Windows NT/2000/XP/Vista/7/8 partitions found, returning to main menu... && pause --wait=5 && goto :finish
write (md)0x300+10 %BWINM1%\r\n%BWINM2%\r\n%BWINM3%\r\n%BWINM4%\r\n%BWINM5%\r\n%BWINM6%\r\n%BWINM7%\r\n%BWINM8%\r\n%BWINM9%\r\n%BWINM10%\r\n%BWINM11%\r\n%BWINM12%\r\n%BWINM13%\r\n%BWINM14%\r\n%BWINM15%\r\ntitle\r\nroot\r\ntitle Return to main menu...\r\nconfigfile /menu.lst\r\n\0 > nul
endlocal
configfile (md)0x300+10
:finish

 

 



#55 steve6375

steve6375

    Platinum Member

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

Posted 25 May 2013 - 05:27 PM

as we say in the UK 'there is more than one way to skin a cat'!

 

Though I am not sure why we say that! :dubbio: 



#56 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 26 May 2013 - 05:00 AM

2 changes:
- for Windows NT I had to change from "chainloader /ntldr" to "chainloader --force --load-segment=0x2000 /ntldr" because it wouldn't load;
- the size of the memory configuration file had to be increased from 4 (2048 bytes) to 10 (5120 bytes) to be sure that it will be enough for those 15 menu entries.

I updated the script in my previous reply.



#57 Wonko the Sane

Wonko the Sane

    The Finder

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

Posted 26 May 2013 - 01:40 PM

as we say in the UK 'there is more than one way to skin a cat'!

 

Though I am not sure why we say that! :dubbio: 

Also, rest assured that the cat won't like *any* of them ;).

 

 

More seriously, it seems like it is not UK, it more likely "comes back" from the US:

http://english.stack...y-to-skin-a-cat

 

 

 

:cheers:

Wonko



#58 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 26 May 2013 - 01:58 PM

As you noticed, Steve, I use some BWINM* variables.

If I try this:

 

set N=1

set BWINM%N%=abcd

echo BWINM1    //it displays "abcd"

echo %BWINM%N%%    //it displays "N%", which is somehow correct, because % is "linked" with the next %.

 

But how can I access (directly, without using other variable) the content of BWINM%N%? Is there a "% %" alternative..?



#59 steve6375

steve6375

    Platinum Member

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

Posted 26 May 2013 - 02:24 PM

write (md)0x3000+1 !BAT\necho %^BWINM%N%%\n > nul && call (md)0x3000+1

will echo

abcd

 

if used in a batch file you may need to use %^BWINM%N%%% ??

 

or better still

call echo %^BWINM%N%%


#60 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 26 May 2013 - 02:36 PM

I don't think it's working, %^BWINM%N%% displays %BWINM1, %^BWINM%N%%% displays %BWINM1%.



#61 steve6375

steve6375

    Platinum Member

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

Posted 26 May 2013 - 02:50 PM

Is this in a batch file or in a menu.lst?

This works fine...

!BAT
set FRED1=A
set FRED2=B
set FRED3=C
set N=0
:LOOP
set /a N=%N%+1 > nul
call echo %^FRED%N%%%
if %N%<=2 goto :LOOP


#62 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 26 May 2013 - 03:36 PM

Yes, it's a batch, it's that script from my previous replies.

Strange is that "call echo %^BWINM%N%%%" echos the content of BWINM1 but "write --offset=0 (md)0x300+10 %^BWINM%N%%%\0" writes "%BWINM1%" as text.

I can't use "echo" to write in the memory file because I have to write at a specific offset...



#63 steve6375

steve6375

    Platinum Member

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

Posted 26 May 2013 - 03:47 PM

I think you are missing the point here, it is that the 'call' is essential!

 

In call echo %^WINM%N%%%  - first the 'call' is run and so the call echo %^WINM%N%%% is translated to become echo %WINM1% - 

then echo %WINM1% is run and we get the desired result.

 

So if you want to use write, then you must use (in a batch file)

call write --offset=0 (md)0x300+10 %^BWINM%N%%%\0


#64 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 26 May 2013 - 04:08 PM

Sorry, yes, I saw "call echo...", but it was not that clear that I have to use "call" in every command. For the moment it appeared that only the %^BWINM%N%%% is the solution...
OK, now I know that it's both :D
Thank you.

But how can I retrieve the %^BWINM%N%%% size with Fn.12?
call Fn.12 "%^BWINM%N%%%" && echo %@retval%       echos 1
call call Fn.12 "%^BWINM%N%%%" && echo %@retval%      still echos 1...



#65 steve6375

steve6375

    Platinum Member

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

Posted 26 May 2013 - 04:18 PM

well, I suggest you put a call in front and see what you get!

 

call call Fn.12 %^BWINM%N%%% ;; echo %@retval%

 

Note that you cannot use  && because the environment is not affected until the whole line has been executed, so you must either split the line or use ;;

P.S. This is why I asked chenall to add the ;;  &; and |; operators!

 

call call Fn.12 %^BWINM%N%%% 

echo %@retval%

 

The example in my tutorial page uses && but it is incorrect! Sorry about that!



#66 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 26 May 2013 - 04:27 PM







call call Fn.12 %^BWINM%N%%% 

echo %@retval%

 

It echos 5 not a few hundred (BWINM1 is long)...



#67 steve6375

steve6375

    Platinum Member

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

Posted 26 May 2013 - 04:31 PM

in a batch file or menu?



#68 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 26 May 2013 - 04:41 PM

Batch file.

Like I said it's that script (batch) showed in my previous replies.

 

I'm trying to transform that static <<write (md)0x300+10 %BWINM1%\r\n%BWINM2%\r\n%BWINM3%\r\n%BWINM4%\r\n%BWINM5%\r\n%BWINM6%\r\n%BWINM7%\r\n%BWINM8%\r\n%BWINM9%\r\n%BWINM10%\r\n%BWINM11%\r\n%BWINM12%\r\n%BWINM13%\r\n%BWINM14%\r\n%BWINM15%\r\ntitle\r\nroot\r\ntitle Return to main menu...\r\nconfigfile /menu.lst\r\n\0>> into a dynamic loop that will write the variables one by one into the memory file.

Plus I will alocate for the memory file as much RAM as is truly needed, not set the maximum.



#69 steve6375

steve6375

    Platinum Member

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

Posted 26 May 2013 - 04:43 PM

Well it works as I posted.

So what is your exact line that you are testing with?



#70 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 26 May 2013 - 04:51 PM







set I=0
set OFFSET=0
set /a N=%N%+1 > nul
:wloop
set /a I=%I%+1 > nul
if %I%>=%N% goto :endwloop
call write --offset=%OFFSET% (md)0x300+10 %^BWINM%I%%% > nul
call call Fn.12 %^BWINM%I%%%
echo %@retval%
pause
set /a OFFSET=%OFFSET%+%@retval% > nul
goto :wloop
:endwloop
#write --offset=%OFFSET% (md)0x300+10 \0 > nul
cat (md)0x300+10
pause

Here is a little different: N is the total number of variables, I is the counter...



#71 steve6375

steve6375

    Platinum Member

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

Posted 26 May 2013 - 04:59 PM

!BAT
set BWINM1=aaaaa
set BWINM2=bbbbb
set BWINM3=ccccc
set N=3
set I=0
set OFFSET=0
set /a N=%N%+1 > nul
:wloop
set /a I=%I%+1 > nul
if %I%>=%N% goto :endwloop
call write --offset=%OFFSET% (md)0x300+10 %^BWINM%I%%% > nul
call call Fn.12 %^BWINM%I%%%
set a=%@retval%
echo %@retval%
pause
echo retval=%@retval% a=%a%
set /a OFFSET=%OFFSET%+%@retval% > nul
:endwloop
#write --offset=%OFFSET% (md)0x300+10 \0 > nul
cat (md)0x300+10
pause

this returns

1

retval=13 a=5

aaaaa

 

set and pause are changing @retval!



#72 steve6375

steve6375

    Platinum Member

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

Posted 26 May 2013 - 05:06 PM

P.S. It seems

pause --wait=10 Hi  ;; echo %@retval%

returns 11 if no key is pressed and it times out or the key value if a key is pressed - e.g. if Enter is pressed retval=13  - so you can tell if a key was pressed (as long as it was not CTRL+K = 11!!!)



#73 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 26 May 2013 - 05:11 PM

Yes, but since echo is before pause and set, it should not affect.

Anyway Ifound the problem:

call call Fn.12 "%^BWINM%I%%%"     instead of the   call call Fn.12 %^BWINM%I%%%

That 5 was from "title" in the variable :D

 

Now it works fine.

Thank you.

 

Regarding "pause" I will think at a way to solve the other problem using this information. Thank you.



#74 steve6375

steve6375

    Platinum Member

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

Posted 26 May 2013 - 05:32 PM

Regarding "pause" I will think at a way to solve the other problem using this information. Thank you.

OK - just trying pause again and now I get 1 returned on timeout  ( could have sworn it was 11 before??)

debug -1 ;; pause --wait=10 Press a letter ;; set /A a=%@retval%+0 > nul ;; if %a%>=0x20 echo -e \%a:~1% was pressed (%a%)!


#75 DavidB

DavidB

    Silver Member

  • Developer
  • 611 posts

Posted 26 May 2013 - 05:52 PM

I modified the script:

 



!BAT
setlocal
clear
echo Please wait, searching...
find --devices=h > (md)0x220+8
set SKIPPED=0
set N=0
set TMSZ=0
set BDN=-1
#########   if the batch was started with /abd as parameter it will not search
#########   on boot device (if it's seen as a HDD). Usually is the USB drive (hd0)
if "%1"=="/abd" if "%?_BOOT:~1,2%"=="hd" set BDN=%?_BOOT:~3,1%
:loop
cat --skip=%SKIPPED% --number=1 --locate=" (hd" (md)0x220+8  | set PPOSB=
if "%PPOSB%"=="" goto endloop
set /a SKIPPED=0x%PPOSB%+7 > nul
cat --skip=%SKIPPED% --number=1 --locate=")" (md)0x220+8  | set PPOSE=
if "%PPOSE%"=="" goto endloop
set /a PPOSL=0x%PPOSE%-0x%PPOSB% > nul
set /a SKIPPED=0x%PPOSB%+1 > nul
cat --skip=%SKIPPED% --length=%PPOSL% --locate=" " (md)0x220+8 && set /a SKIPPED=0x%PPOSB%+7 > nul && goto :loop
cat --skip=%SKIPPED% --length=%PPOSL% --locate="," --number=1 (md)0x220+8 | set CPOS=
if "%CPOS%"=="" set /a SKIPPED=0x%PPOSB%+7 > nul && goto :loop
set /a PNL=0x%PPOSE%-0x%CPOS%-1 > nul
set /a SKIPPED=0x%CPOS%+1 > nul
cat --skip=%SKIPPED% --length=%PNL% (md)0x220+8 | set PN=
set /a HDNL=0x%CPOS%-0x%PPOSB%-4 > nul
set /a SKIPPED=0x%PPOSB%+4 > nul
cat --skip=%SKIPPED% --length=%HDNL% (md)0x220+8 | set HDN=

if %PN%>=4 goto :notgood
if %BDN%==%HDN% goto notgood
checkrange 0x06:0x0e parttype (hd%HDN%,%PN%) > nul || goto :notgood

ls (hd%HDN%,%PN%)/ > (md)0x300+8
cat --locate=\0 --number=1 (md)0x300+8 | set ENDFILE=
set /a ENDFILE=0x%ENDFILE% > nul
if not "%ENDFILE%"=="0" write --offset=%ENDFILE% (md)0x300+8 \ \0 > nul

cat --locate=" ntldr " --number=1 (md)0x300+8 > nul || goto :nont
cat --length=0 (hd%HDN%,%PN%)/ntldr | set NTS=
set /a NTS=0x%NTS:~14% > nul
if %NTS%<=74999 goto notgood
set /a N=%N%+1 > nul
set CLCMD=chainloader
if %NTS%>=218976 set OS=XP && goto :esnt
if %NTS%>=185208 set OS=2000 && goto :esnt
set OS=NT
set CLCMD=chainloader --force --load-segment=0x2000
:esnt
if %HDN%==0 set HDNT=first && set HDNTR=USB drive
if %HDN%==1 set HDNT=second && set HDNTR=first internal HDD
if %HDN%==2 set HDNT=third && set HDNTR=second internal HDD
if %HDN%==3 set HDNT=fourth && set HDNTR=third internal HDD
if %HDN%>=4 set HDNT=%HDN%th && set /a HDNN=%HDN%+1 > nul && set HDNTR=%HDN%th internal HDD
if %HDN%==0 set REMAP=
if %HDN%==0 set AFTERR=
if %HDN%>=1 set REMAP=\r\nmap (hd%HDN%) (hd0)\r\nmap (hd0) (hd%HDN%)\r\nmap --rehook
if %HDN%>=1 set AFTERR=\ \&\& boot\r\nmap (hd%HDN%) (hd0)\r\nmap (hd0) (hd%HDN%)\r\nmap --rehook\r\nroot (bd) \> nul\r\n%CLCMD% (hd%HDN%,%PN%)/ntldr
if %PN%==0 set PNT=first
if %PN%==1 set PNT=second
if %PN%==2 set PNT=third
if %PN%==3 set PNT=fourth


set BWINM%N%=title Boot to Windows %OS% on %HDNT% HDD, %PNT% partition\\nUsually the %HDNTR%...%REMAP%\r\nroot (hd0,%PN%) \> nul\r\%CLCMD% /ntldr%AFTERR%\r\n
call call Fn.12 "%^BWINM%N%%%"
set /a TMSZ=%TMSZ%+%@retval% > nul
:nont

cat --locate=" bootmgr " --number=1 (md)0x300+8 > nul || goto :nomgr
cat --length=0 (hd%HDN%,%PN%)/bootmgr | set MGRS=
set /a MGRS=0x%MGRS:~14% > nul
if %MGRS%<=199999 goto notgood
if %MGRS%==438840 set OS=Vista && goto :esmgr
if %MGRS%>=390971 set OS=8 && goto :esmgr
if %MGRS%>=358410 set OS=7 && goto :esmgr
set OS=Vista
:esmgr
set /a N=%N%+1 > nul
if %HDN%==0 set HDNT=first && set HDNTR=USB drive
if %HDN%==1 set HDNT=second && set HDNTR=first internal HDD
if %HDN%==2 set HDNT=third && set HDNTR=second internal HDD
if %HDN%==3 set HDNT=fourth && set HDNTR=third internal HDD
if %HDN%>=4 set HDNT=%HDN%th && set /a HDNN=%HDN%+1 > nul && set HDNTR=%HDN%th internal HDD
if %HDN%==0 set REMAP=
if %HDN%==0 set AFTERR=
if %HDN%>=1 set REMAP=\r\nmap (hd%HDN%) (hd0)\r\nmap (hd0) (hd%HDN%)\r\nmap --rehook
if %HDN%>=1 set AFTERR=\ \&\& boot\r\nmap (hd%HDN%) (hd0)\r\nmap (hd0) (hd%HDN%)\r\nmap --rehook\r\nroot (bd) \> nul\r\nchainloader (hd%HDN%,%PN%)/bootmgr
if %PN%==0 set PNT=first
if %PN%==1 set PNT=second
if %PN%==2 set PNT=third
if %PN%==3 set PNT=fourth

set BWINM%N%=title Boot to Windows %OS% on %HDNT% HDD, %PNT% partition\\nUsually the %HDNTR%...%REMAP%\r\nroot (hd0,%PN%) \> nul\r\nchainloader /bootmgr%AFTERR%\r\n
call call Fn.12 "%^BWINM%N%%%"
set /a TMSZ=%TMSZ%+%@retval% > nul
:nomgr

:notgood

set /a SKIPPED=0x%PPOSE%+2 > nul
goto :loop
:endloop
if %N%==0 endlocal && clear && echo No bootable Windows NT/2000/XP/Vista/7/8 partitions found, returning to main menu... && pause --wait=5 && goto :finish

set I=0
set OFFSET=0
set /a N=%N%+1 > nul
call Fn.12 "\r\ntitle\r\nroot\r\ntitle Return to main menu...\r\nconfigfile /menu.lst\r\n\0"
set /a MBSZ=%TMSZ%+%@retval%/512+1 > nul
:wloop
set /a I=%I%+1 > nul
if %I%>=%N% goto :endwloop
call write --offset=%OFFSET% (md)0x300+%MBSZ% %^BWINM%I%%% > nul
call call Fn.12 "%^BWINM%I%%%"
set /a OFFSET=%OFFSET%+%@retval% > nul
goto :wloop
:endwloop
write --offset=%OFFSET% (md)0x300+%MBSZ% \r\ntitle\r\nroot\r\ntitle Return to main menu...\r\nconfigfile /menu.lst\r\n\0 > nul

endlocal && set MBSZ=%MBSZ%
configfile (md)0x300+%MBSZ%
:finish





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users