1

Topic: unexpected makeboot.bat console output

Am trying to create a bootable Flash USB for gparted.  I copied files from gparted-live-0.6.1-2.zip to the Flash drive, which is drive F: on my system.  From a WinXP command prompt, I changed to drive F:\utils\win32 and executed makeboot.bat and saw this:
-----------------------------------------------------------------
This batch file will prepare drive F: for boot using syslinux!
-----------------------------------------------------------------


--------------------- WARNING!: ---------------------------------

Run this file from your portable USB device ONLY.
Running this file from your hard drive may overwrite your current
Master Boot Record (MBR) and render your Windows Operating System
un-bootable. YOU HAVE BEEN WARNED!

This batch file is offered in hopes that it will be useful and
comes with absolutely no warranty. USE AT YOUR OWN RISK!

-----------------------------------------------------------------

C:
C:/ACBLSCOR
C:/ACBLSCOR/ACBL.BAT
C:/ACBLSCOR/ACBL.ICO
C:/ACBLSCOR/ACBL.PIF
C:/ACBLSCOR/ACBL3-1.LZH
...
with the output continuing to scroll through what appears to be a complete file-by-file listing of my C: drive, until I panicked and Ctrl-C'd to kill the batch file.  Is this normal?  An analogous procedure to create a clonezilla usb flash drive worked perfectly yesterday, without this output.

Nervous in New Hampshire.

2

Re: unexpected makeboot.bat console output

SOLVED
The spurious recursive directory listing is generated by a line in makeboot.bat ahead of the syslinux execution:
cd | find "%system%" && echo ...
On my machine "find" is "find (GNU findutils) 4.4.0" via cygwin.   The invocation resolves to "find c:" and generates the output.

Perhaps there is a cleaner way than "cd | find" to test the current drive letter against the system drive letter?

3

Re: unexpected makeboot.bat console output

Thanks for this bug report. Actually I am not so familiar with MS Windows system, so if you find a better way to implement that, please tell us. Thanks.

Steven.

4

Re: unexpected makeboot.bat console output

My first guess is that the problem arises because the batch script is expecting the Windows command "find" which uses quite different parameters than the GNU/Linux "find" command.

I did a quick internet search and following is a link that states a way to determine the current drive letter in Windows:
Current drive letter in batch script

The relevant code snippet is:

set drive=%cd:~0,3%
echo %drive%

5

Re: unexpected makeboot.bat console output

The completely general solution is tricky.  Drives can be aliases ("subst") and users can put any "find.exe" they want in their path.  The first line of defense could be to change the makeboot.bat script line:
cd | find "%systemdrive%" ...
to:
cd | "%windir%\system32\find.exe" "%systemdrive%" ...
so only the find.exe in the Windows system directory will be invoked.
Another possibility would be to use Windows' findstr.exe instead of find.exe:
cd | "%windir%\system32\findstr.exe" /B /I "%systemdrive%" ...
where the /B means match at beginning of string and /I means ignore case.
I often find that an executable is better than a batch file.  If you want, I will write a short program to read the current drive via a software interrupt; that could even check "subst".  Let me know if you think it is justified.
Another option would be to lock the %systemdrive% temporarily by making it read-only, then trying the syslinux call, then unlocking.  This should be robust but may open a can of user-permissions worms.
If I have been the first one to notice a problem, I would guess that the existing system is fine and no change is needed.  At least the problem is understood, so a few words in the documentation about "find.exe" and its expected location in the path should be entirely sufficient.
Thanks to all of you who support such wonderful tools as gparted and syslinux!

6

Re: unexpected makeboot.bat console output

gedakc wrote:

My first guess is that the problem arises because the batch script is expecting the Windows command "find" which uses quite different parameters than the GNU/Linux "find" command.

I did a quick internet search and following is a link that states a way to determine the current drive letter in Windows:
Current drive letter in batch script

The relevant code snippet is:

set drive=%cd:~0,3%
echo %drive%

===================================================

Very nice.  Thanks for opening my eyes to the Windows substring syntax.  Two minor follow-up points:  1 - How far back, in Windows versions, does this syntax go?  2 - I think you want %cd:~0,2% because %systemdrive% does not have a trailing '\', at least on my WinXP installation.

7

Re: unexpected makeboot.bat console output

lryoung wrote:

How far back, in Windows versions, does this syntax go?

The syntax is valid at least back to Windows NT 4.0.  I expect that all currently supported versions of Windows now work with this syntax.

8

Re: unexpected makeboot.bat console output

Thanks!
"cd | "%windir%\system32\findstr.exe" /B /I "%systemdrive%" ..." is an easy way to replace the existing one. I will use this in the next release.

Steven.