Managing MBR's by jaclaz MBRBatch Release 0.01 ALPHA
#26
Posted 06 October 2008 - 09:00 AM
Reason is, i plan to use a different utility to make partition dump faster, that is why this didnt come in my mind at first place. I couldnt make things i want with savepart on this subject, ghost is doing exactly what i want with speed (and with an unwanted correction) but i dont want to use a nonfree utility.
Probably when i find a nice nonfree utility that does diskcopy, i will need that drive number
#27
Posted 06 October 2008 - 05:21 PM
Beside this unsuccess for now,
bpatcher.exe yUSB.img 1C2 0C
didnt work with 4gb image file
so i choose another way to add a correction for 0B-0C and 06-0E,
i added lines in bold to mkimg.cmd
ECHO Press any key to unmount the image and uninstall vdk.exe...
ECHO.
PAUSE
)
VDK.EXE REMOVE
if "%PartType%" == "0E" goto :correctionfix
if "%PartType%" == "0C" goto :correctionfix
goto correctioncontinue
:correctionfix
del /q /f %Targetfile%512.mbr
del /q /f %Targetfile%512_patch.mbr
dsfo %Targetfile% 0 512 %Targetfile%512.mbr
copy /y %Targetfile%512.mbr %Targetfile%512_patch.mbr
bpatcher.exe %Targetfile%512.mbr 1C2 %PartType%
dsfi %Targetfile% 0 512 %Targetfile%512.mbr
:correctioncontinue
GOTO :EOF
in my tests everything seems to work fine, but i can be mistaken! please confirm that the lines are nice to add to mkimg.cmd?
#28
Posted 06 October 2008 - 06:23 PM
This:
copy /y %Targetfile%512.mbr %Targetfile%512_patch.mbr
should be:
copy /b %Targetfile%512.mbr %Targetfile%512_patch.mbr
Is it possible that bpatcher has a filesize limit?
jaclaz
#29
Posted 06 October 2008 - 06:57 PM
i put new notes to post 14 and uploaded file with /b
after some trials with bpatcher i guess limit is between 1600 MB and 1700 MB
If not demanding much can you give me clue to find drive number with using %DRIVE% ?
#30
Posted 06 October 2008 - 07:22 PM
If not demanding much can you give me clue to find drive number with using %DRIVE% ?
I guess you need to use another utility , like MBRFIX or MBRWIZ, just to name a couple, but there are several more, check also among the "minor" utilities by Olof:
http://www.ltr-data.se/opencode.html
Or you could try re-starting VDK and use
VDK IMAGEsince VDK has been restarted after the USB stick has been detected, it's first drive (but you can also start just one drive) number should be one more that of the USB stick.
jaclaz
#31
Posted 07 October 2008 - 09:08 AM
http://lancelot.winb.../5F/nfgdump.exe
so now before unmounting image, correction can be made by modifying mkimg.cmd
REM CORRECTION on vdk mounted image
for /f "tokens=3 delims=\Dev " %%A in ('nfgdump list^|FIND "%DRIVE%"') do SET Drivenumber=%%A
del /q /f %Targetfile%512a.mbr
del /q /f %Targetfile%512a_patch.mbr
dsfo \\.\PHYSICALDRIVE%Drivenumber% 0 512 %Targetfile%512a.mbr
copy /b %Targetfile%512a.mbr %Targetfile%512a_patch.mbr
bpatcher.exe %Targetfile%512a_patch.mbr 1C2 %PartType%
dsfi \\.\PHYSICALDRIVE%Drivenumber% 0 512 %Targetfile%512a_patch.mbr
VDK.EXE REMOVE
Again I need confirmation ? (sorry, but i am still a rookie, it will take looong time to graduate )
I didnt use If closes this time (if "%PartType%" == "0E" ...), maybe i do right, maybe wrong??
and if confirmed yes, than the previous modification to change %targetfile% would be useless???
#32
Posted 07 October 2008 - 09:27 AM
The latest snippet will uncoditionally re-write the partition type, this can take a few seconds, which are unneeded when written partition type already equals %parttype%.
Also, why you need using two files?:
%Targetfile%512a.mbr
%Targetfile%512a_patch.mbr
cannot you just patch the extracted %Targetfile%512a.mbr?
For the record, nfgdump is an Open Source project, the homepage is here:
http://sourceforge.n...ojects/nfgdump/
jaclaz
#33
Posted 07 October 2008 - 09:40 AM
a check with %parttype% would be advisable
So final 1 is that:
REM CORRECTION on vdk mounted image
if "%PartType%" == "0E" goto :correctionfixa
if "%PartType%" == "0C" goto :correctionfixa
goto correctionacontinue
:correctionfixa
for /f "tokens=3 delims=\Dev " %%A in ('nfgdump list^|FIND "%DRIVE%"') do SET Drivenumber=%%A
del /q /f %Targetfile%512a.mbr
del /q /f %Targetfile%512a_patch.mbr
dsfo \\.\PHYSICALDRIVE%Drivenumber% 0 512 %Targetfile%512a.mbr
copy /b %Targetfile%512a.mbr %Targetfile%512a_patch.mbr
bpatcher.exe %Targetfile%512a_patch.mbr 1C2 %PartType%
dsfi \\.\PHYSICALDRIVE%Drivenumber% 0 512 %Targetfile%512a_patch.mbr
:correctionacontinue
VDK.EXE REMOVE
yes one file is enough, i use this method to see the change before/after during trials As i am a rookie, i double (in this case triple, 2 files + created image file) check as much as possible, i loose lots of times with a gain of making less (but not zero) mistakes.Also, why you need using two files?
cannot you just patch the extracted %Targetfile%512a.mbr?
So final2 can be this:
REM CORRECTION on vdk mounted image
if "%PartType%" == "0E" goto :correctionfixa
if "%PartType%" == "0C" goto :correctionfixa
goto correctionacontinue
:correctionfixa
for /f "tokens=3 delims=\Dev " %%A in ('nfgdump list^|FIND "%DRIVE%"') do SET Drivenumber=%%A
del /q /f %Targetfile%512a.mbr
del /q /f %Targetfile%512a_patch.mbr
dsfo \\.\PHYSICALDRIVE%Drivenumber% 0 512 %Targetfile%512a.mbr
copy /b %Targetfile%512a.mbr %Targetfile%512a_patch.mbr
bpatcher.exe %Targetfile%512a_patch.mbr 1C2 %PartType%
dsfi \\.\PHYSICALDRIVE%Drivenumber% 0 512 %Targetfile%512a_patch.mbr
del /q /f %Targetfile%512a.mbr
del /q /f %Targetfile%512a_patch.mbr
:correctionacontinue
VDK.EXE REMOVE
#34
Posted 07 October 2008 - 10:08 AM
REM CORRECTION on vdk mounted image if "%PartType%" == "0E" CALL :correctionfixa if "%PartType%" == "0C" CALL :correctionfixa VDK.EXE REMOVE GOTO :EOF :correctionfixa for /f "tokens=3 delims=\Dev " %%A in ('nfgdump list^|FIND "%DRIVE%"') do SET Drivenumber=%%A IF EXIST %Targetfile%512a.mbr del /q /f %Targetfile%512a.mbr dsfo \\.\PHYSICALDRIVE%Drivenumber% 0 512 %Targetfile%512a.mbr bpatcher.exe %Targetfile%512a.mbr 1C2 %PartType% dsfi \\.\PHYSICALDRIVE%Drivenumber% 0 512 %Targetfile%512a.mbr del /q /f %Targetfile%512a.mbr GOTO :EOF
jaclaz
#35
Posted 07 October 2008 - 12:05 PM
I made some changes so correction made before explorer executed (so someone who look mbr info of mounted disk will see final mbr of image, and a diskcopy utility can be used at this stage), i guess this time i did all right?
IF /I NOT %NoPrompts%.==/np. (
if exist .\BootFiles\NTLDR copy /y ".\BootFiles\NTLDR" %drive%
if exist .\BootFiles\NTDETECT.COM copy /y ".\BootFiles\NTDETECT.COM" %drive%
if exist .\BootFiles\boot.ini copy /y ".\BootFiles\boot.ini" %drive%
if exist .\BootFiles\grldr copy /y ".\BootFiles\grldr" %drive%
if exist .\BootFiles\MENU.LST copy /y ".\BootFiles\MENU.LST" %drive%
xcopy .\ExtraFiles\*.* %drive% /s /y /e /h
)
REM CORRECTION on vdk mounted image
if "%PartType%" == "0E" CALL :correctionfixa
if "%PartType%" == "0C" CALL :correctionfixa
START /WAIT %SystemRoot%\explorer.exe %drive%
ECHO.
ECHO Press any key to unmount the image and uninstall vdk.exe...
ECHO.
PAUSE
VDK.EXE REMOVE
vdk.exe open * %Targetfile% /rw
VDK.EXE REMOVE
GOTO :EOF
:correctionfixa
for /f "tokens=3 delims=\Dev " %%A in ('nfgdump list^|FIND "%DRIVE%"') do SET Drivenumber=%%A
IF EXIST %Targetfile%512a.mbr del /q /f %Targetfile%512a.mbr
dsfo \\.\PHYSICALDRIVE%Drivenumber% 0 512 %Targetfile%512a.mbr
bpatcher.exe %Targetfile%512a.mbr 1C2 %PartType%
dsfi \\.\PHYSICALDRIVE%Drivenumber% 0 512 %Targetfile%512a.mbr
del /q /f %Targetfile%512a.mbr
GOTO :EOF
:MKIMGI_TF
#36
Posted 08 October 2008 - 06:07 PM
IF /I NOT %NoPrompts%.==/np. (
This should mean that in "interactive mode", NO matter what the user actually wants, you "force" him to copy:
NTLDR
NTDETECT.COM
boot.ini
grldr
MENU.LST
\ExtraFiles\*.*
This is in my view WRONG, you should ask for user confirmation.
(and you can remove all /Y switches, unneeded when copy is run from batch )
WARNING PSEUDOCODE, NEEDS testing:
SET Confirm=N IF /I NOT %NoPrompts%.==/np. ( CLS ECHO Do you want to copy bootfiles to the mounted image? SET /P Confirm= ) IF NOT /I %Confirm%.==Y. GOTO :SkipThis FOR %%A in (NTLDR NTDETECT.COM boot.ini grldr MENU.LST) DO ( if exist .\BootFiles\%%A copy .\BootFiles\%%A %drive% ) xcopy .\ExtraFiles\*.* %drive% /s /y /e /h :SkipThis
The xcopy command parameters and switches should be checked :
http://www.msfn.org/...8...0.html&st=9
Then, one may add a switch, like /npcf for "No Prompts & Copy Files", to allow for file copying when called with all parameters.
jaclaz
#37
Posted 09 October 2008 - 08:49 AM
xcopy was added switches, we do chicken right now i hope
ps:
at topic http://www.msfn.org/...8...0.html&st=9 i couldnt find CDCheck utility from this link: http://www.elpros.si/CDCheck/ . Maybe company change or they decide not to give this utility anymore!
This should mean that in "interactive mode", NO matter what the user actually wants, you "force" him to copy:
This is in my view WRONG, you should ask for user confirmation.
In my defense,
if a user create a folder \BootFiles\ and put files in it, and
if a user create a folder \ExtraFiles\ and put files in it, than it means user want these files to be copied.
In my usage i rename folder when i dont want to copy files, which will be very understandable for a new user because at first there are no \BootFiles\ or \ExtraFiles\ folder.
Also
In interface asking user "Do you want to copy bootfiles to the mounted image?" will be useless if there is no such folder created and files added. (maybe boot files files can be checked and if one exists this question can be asked and a check of extrafiles folder may/may not be necessary)
Ideas are for to share, not to argue, please dont think that i dont like the idea of confirmation, i only share my ideas.
By making some modification I wrote this and checked working
SET Confirm=Y IF /I NOT %NoPrompts%.==/np. ( CLS ECHO Do you want to copy bootfiles and extra files to the mounted image? ECHO For YES press any key ECHO For NO press N SET /P Confirm= ) IF /I NOT %Confirm%==Y GOTO :Skipcopybootextrafiles FOR %%A in (NTLDR NTDETECT.COM boot.ini grldr MENU.LST) DO ( if exist .\BootFiles\%%A copy .\BootFiles\%%A %drive% ) xcopy .\ExtraFiles\*.* %drive%\*.* /i /s /e /r /v /k /f /c /h :Skipcopybootextrafiles
I use SET Confirm=Y because as i wrote before, i assume if user create folder and put files, user wants to copy files without prompt. But also i have opposite scenario in mind that results opposite.
probably more perfect solution for your offer is
or more precisely having 2 switches for bootfiles and extrafiles + checking bootfiles files if exist to ask copy confirm + check extra files folder existand check to ask another question to copy filesone may add a switch, like /npcf
So for now, i decide not to add this lines and let user decide to have(or not) these folders/files in directory, or switch by renaming folders which is really easy/practical.
#38
Posted 09 October 2008 - 09:31 AM
No need whatsoever to "defend" yourself.In my defense,
...
What about:
If NOT EXIST .\bootfiles\nul.ext :Skipcopybootextrafiles If NOT EXIST .\ExtraFiles\nul.ext :Skipcopybootextrafiles ... SET Confirm=Y ...
CDCHECK new "home":
http://www.kvipu.com/CDCheck/
06.07.2006 site Site moved to kvipu.com domain
jaclaz
#39
Posted 09 October 2008 - 10:33 AM
[codebox] If NOT EXIST .\BootFiles goto :Skipcopybootextrafiles SET Confirm=Y IF /I NOT %NoPrompts%.==/np. ( CLS ECHO Do you want to copy BootFiles to the mounted image? ECHO For YES press any key (or just ENTER) ECHO For NO press N and ENTER SET /P Confirm= ) IF /I NOT %Confirm%==Y GOTO :Skipcopybootextrafiles FOR %%A in (NTLDR NTDETECT.COM boot.ini grldr MENU.LST) DO ( if exist .\BootFiles\%%A copy .\BootFiles\%%A %drive% ) :Skipcopybootfiles If NOT EXIST .\ExtraFiles goto :Skipcopyextrafiles SET Confirm=Y IF /I NOT %NoPrompts%.==/np. ( CLS ECHO Do you want to copy ExtraFiles to the mounted image? ECHO For YES press any key (or just ENTER) ECHO For NO press N and ENTER SET /P Confirm=
)
xcopy .\ExtraFiles\*.* %drive%\*.* /i /s /e /r /v /k /f /c /h
:Skipcopyextrafiles
[/codebox]
#40
Posted 09 October 2008 - 11:16 AM
Good idea, with some changes i made, Please confirm this code Capitan, i will add after your confirmation.
But again, something like this:
If NOT EXIST .\BootFiles goto :Skipcopybootextrafiles IF /I NOT %NoPrompts%.==/np. CALL :docopyfiles Bootfiles .... IF /I NOT %NoPrompts%.==/np. CALL :docopyfiles Extrafiles .... :docopyfiles SET Confirm=Y CLS ECHO Do you want to copy %1 to the mounted image? ECHO For YES press any key (or just ENTER) ECHO For NO press N and ENTER SET /P Confirm= IF /I NOT %Confirm%==Y GOTO :EOF IF NOT %1.==BootFiles. GOTO :Skipbootfiles FOR /F "tokens=1 delims=" %%A in ('DIR /b .\Bootfiles\' ) DO ( copy .\BootFiles\%%A %drive% ) :Skipbootfiles IF NOT %1.==Extrafiles. GOTO :Skipextrafiles xcopy .\%1\*.* %drive%\*.* /i /s /e /r /v /k /f /c /h :Skipextrafiles GOTO :EOF .....
might be more "openminded", allowing to copy more files that the "usual" ones....
jaclaz
#41
Posted 09 October 2008 - 03:38 PM
might be more "openminded", allowing to copy more files that the "usual" ones....
so instead of codes of post #39 , should i use this one (please check&confirm, as you know i use try/find method with trying hard to understand )
If NOT EXIST .\BootFiles goto :Skipcopybootfilesxx IF /I NOT %NoPrompts%.==/np. CALL :docopyfiles BootFiles :Skipcopybootfilesxx If NOT EXIST .\ExtraFiles goto :Skipcopyextrafilesxx IF /I NOT %NoPrompts%.==/np. CALL :docopyfiles Extrafiles :Skipcopyextrafilesxx goto :Skipcopyfilesxx :docopyfiles SET Confirm=Y CLS ECHO Do you want to copy %1 to the mounted image? ECHO For YES press any key (or just ENTER) ECHO For NO press N and ENTER SET /P Confirm= IF /I NOT %Confirm%==Y GOTO :EOF IF NOT %1.==BootFiles. GOTO :Skipbootfiles FOR /F "tokens=1 delims=" %%A in ('DIR /b .\Bootfiles\' ) DO ( copy /y .\BootFiles\%%A %drive% ) IF NOT %1.==Extrafiles. GOTO :Skipextrafiles :Skipbootfiles xcopy .\%1\*.* %drive%\*.* /i /s /e /r /v /k /f /c /h :Skipextrafiles GOTO :EOF :Skipcopyfilesxx
#42
Posted 09 October 2008 - 04:39 PM
Theoretically a program is more readable (and snippets form it more easily "porteble"/"reusable") the more it has a "small" main part and a number of sub-routines.
jaclaz
#43
Posted 09 October 2008 - 05:41 PM
Well, yes
as Capitan compromise, I uploaded new file and added recent changes to post #14
As i read from a site a while ago, you are a bible jaclaz
#44
Posted 09 October 2008 - 07:12 PM
as Capitan compromise, I uploaded new file and added recent changes to post #14
As i read from a site a while ago, you are a bible jaclaz
I have been called all kind of names....
http://www.boot-land...?...=2958&st=15
though I think that it is mainly "flattery", I hope to not offend anyone, as it is really not intended , but sometimes I think to appear like some kind of "civilized" explorer marooned off to a shore where the natives get bewildered by the lighting of a match (unrealistically dry after the wreckage of the ship and the long swim ).
I find that the little things I try to share are mostly known, easily findable, very rarely I "produce" something that is "new", or "original", I simply try to keep together the bits and pieces related to a very "narrow" topic, basically the MBR and bootsector: 512 + 512 bytes, and a handful of files, NTLDR, NTDETECT.COM, BOOT.INI, grldr and menu.lst....
jaclaz
#45
Posted 27 March 2013 - 09:00 PM
Good Job Jaclaz
well this post is for experts only so it will be better to make explanation for starters...for
---
save MBR code of disk or an mbr file.
Copy MBR code of disk or an mbr file to another file.
Can write the MBR code of source file to destdrive.
Creates MBR from a 2k/XP file saving it as targetfile.
Show partition entries in source MBR(either a MBR file or a drive).
Edit one partition entry in MBR file.
Patches sourcefile with "HP" USB/int13 modification.
create HD like images of arbitrary size and to format them with various geometries.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users