Thanks steve6375, I am watching your work on these tools and appreciate it, very handy indeed.
However, I need to prepare USB disks from a script so they launch grub4dos, at the same time I'd like to avoid unnecessary chainloadings, from ms-dos or whatever, as I always prefer to keep things as simple as possible.
Having said that I am not sure how any of your tools would help with my problem.
Do you have any observations why and when Vista/7 lock volumes, making writing of BS/MBR to them impossible? How do you unlock them, if that's the case, in your application? Can this be done in similar fashion by grubinst? That's a field I am very novice in.
You can prepare a USB stick using RMPARTUSB.
You can run RMPARTUSB FIND > getdrv.cmd
then call getdrv.cmd
This will get the drive number as an environment variable and drive letter (assuming one USB drive present)
Then you can run RMPARTUSB DRIVE=%DRIVE% NTFS MSDOS (see doc for syntax/parameters)
(suggest run RMPARTUSB FIND and call getdrv.cmd again here in case there was no driveletter originally)
Then you can use Grubinst to install Grub4DOS (use (hd%DRIVE% )
Then xcopy to copy files (inc grldr) to the USB drive (use %DRIVELETTER%)
If you still get problems with grubinst, then just skip the grubinst command and rename grldr to ntldr on the USB stick and use RMPARTUSB DRIVE=%DRIVE% NTFS NTLDR (or FAT32 instead of NTFS).
For your info, I try to dismount the volume letter of the USB drive as follows:
Open_Volume (Mid(strvol, 1, 2)) 'get lngHandle for volume letter
MyLock_Volume (lngHandle) 'may fail but FormatEX may work anyway !
MyDismount_Volume (lngHandle) 'may fail but still may enable FormatEX to work
MyUnlock_Volume (lngHandle)
CloseHandle (lngHandle)
HTH