victor888 Posted December 8, 2008 Author Posted December 8, 2008 test again on another pcresult without /v switchC: 0,0 IDE FixedD: 0,1 IDE FixedE: 0,2 IDE FixedF: 0,3 IDE FixedG: 0,4 IDE FixedH: IDE CD-ROMI: 2,0 USB RemovableJ: FixedK: FixedM: FixedSame result as previous test. J,K,L are usb hard disk drive letters, no USB type found.result with /v switchPHN=2,0Ph_Drive_Bus_0=IDEPh_Drive_Bus_1=USBPh_Drive_Bus_2=USBPH_drive_Letter_0_0=C:PH_drive_Letter_0_1=D:PH_drive_Letter_0_2=E:PH_drive_Letter_0_3=F:PH_drive_Letter_0_4=G:PH_drive_Letter_2_0=I:Ph_drive_PIP_2="7&21572299&0"Ph_drive_Sig_0=ca2319a4Ph_Drive_Type_0=FixedPh_Drive_Type_1=FixedPh_Drive_Type_2=RemovableDrive_Bus_H=IDEDrive_Data=000000005C005C003F005C00530054004F005200410047004500230056006F006C0075006D006500230031002600330030006100390036003500390038002600300026005300690067006E0061007400750072006500320031003900450030004600430043004F00660066007300650074003900340037003500350044003800300030004C0065006E00670074006800430034003100330034003000300023007B00350033006600350036003300300064002D0062003600620066002D0031003100640030002D0039003400660032002D003000300061003000630039003100650066006200380062007D000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005C005C003F005C0056006F006C0075006D0065007B00360034006200320031006400620065002D0062006600350037002D0031003100640064002D0039003200340033002D003000300031003300320030003500370039003100340031007D005C0Drive_Letter_C=CDrive_Letter_D=DDrive_Letter_E=EDrive_Letter_F=FDrive_Letter_G=GDrive_Letter_H=HDrive_Letter_I=IDrive_Letter_J=JDrive_Letter_K=KDrive_Letter_M=MDrive_REF_C={317bb1be-bc5b-11dd-8642-806d6172696f}Drive_REF_D={317bb1bf-bc5b-11dd-8642-806d6172696f}Drive_REF_E={317bb1c0-bc5b-11dd-8642-806d6172696f}Drive_REF_F={317bb1c1-bc5b-11dd-8642-806d6172696f}Drive_REF_G={317bb1c2-bc5b-11dd-8642-806d6172696f}Drive_REF_H={2a4fb5f2-bf44-11dd-9240-806d6172696f}Drive_REF_I={5199df13-c010-11dd-9247-001320579141}Drive_REF_J={64b21dbc-bf57-11dd-9243-001320579141}Drive_REF_K={64b21dbd-bf57-11dd-9243-001320579141}Drive_REF_M={64b21dbe-bf57-11dd-9243-001320579141}Drive_Sig_C=ca2319a4Drive_Sig_D=ca2319a4Drive_Sig_E=ca2319a4Drive_Sig_F=ca2319a4Drive_Sig_G=ca2319a4Drive_Sig_J=219e0fccDrive_Sig_K=219e0fccDrive_Sig_M=219e0fccDrive_Type_C=FixedDrive_Type_D=FixedDrive_Type_E=FixedDrive_Type_F=FixedDrive_Type_G=FixedDrive_Type_H=CD-ROMDrive_Type_I=RemovableDrive_Type_J=FixedDrive_Type_K=FixedDrive_Type_M=FixedI have to point out, in order to have a good speed, use as less REQ QUERY in the FOR circle as possible.I am still checking your code.
jaclaz Posted December 8, 2008 Posted December 8, 2008 @Victor888I know you'll simply LOVE this snippet:@ECHO OFFSETLOCAL ENABLEDELAYEDEXPANSIONSETLOCAL ENABLEEXTENSIONSGOTO :Start::THIS IS LINE #5 in this batchselect disk 0detail diskEXIT::THIS IS LINE #9 in this batchselect disk 1detail diskEXIT::THIS IS LINE #13 in this batchselect disk 2detail diskEXIT::THIS IS LINE #17 in this batchselect disk 3detail diskEXIT::THIS IS LINE #21 in this batchselect disk 4detail diskEXIT::THIS IS LINE #25 in this batchselect disk 5detail diskEXIT::THIS IS LINE #29 in this batchselect disk 6detail diskEXIT:StartFOR /F "tokens=2,7" %%A IN ('ECHO list disk^|diskpart^|FIND "B"') DO SET DP_disks=!DP_disks! %%AFOR %%A IN (%DP_disks%) DO (SET /A DP_Line#=%%A*4+5FOR /F "skip=8 tokens=1,2,3 delims=: " %%B IN ('MORE +!DP_Line#! %~dpnx0^|diskpart.exe^|FIND /v /i "DISKPART"') DO (ECHO working....ECHO ....ECHO %%B %%C %%DIF %%B.==Disk. SET DP_disk_sig_%%A=%%DIF %%B.==Volume. IF NOT %%C.==n.. SET DP_disk_letters_%%A=!DP_disk_letters_%%A! %%DIF %%B.==Type. SET DP_disk_bus_%%A=%%C))CLS&SET DP_diskGOTO :EOFjaclaz
victor888 Posted December 8, 2008 Author Posted December 8, 2008 Dizzy.I study registry enough, that I wrote a paper about registry searching in Chinese.I have no time to translate.http://bbs.wuyou.com/viewthread.php?tid=13...;extra=page%3D2In fact to detemine the signature belongs to which disk if more than one hard disk installed there is a better way:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\STORAGE\Volume\1&30a96598&0&SignatureA8E1B9D2Offset7E00LengthXXXXXXXXThe key "driver",{71A27CDD-812A-11D0-BEC7-08002BE2092F}\0022,the last two number "22" tells the disk number. That is the driver value of disk 0 is smaller than that of disk 1, the latter is smaller than that of disk 2, etc.Under pe, no driver key exist.
jaclaz Posted December 8, 2008 Posted December 8, 2008 Boy, do I love Google translate!:http://translate.google.com/translate?u=ht...en&ie=UTF-8This is great:The Scarlet Letter is part of the sub-signatureNathaniel Hawthorne would be very glad for this publicity to his book.... jaclaz
jaclaz Posted December 9, 2008 Posted December 9, 2008 (edited) A bettered snippet, that allows to put the diskpart batch commands at the end of the file, indexing them automatically and making it run much faster:@ECHO OFFSETLOCAL ENABLEDELAYEDEXPANSIONSETLOCAL ENABLEEXTENSIONSFOR /F "tokens=1 delims=[]" %%A in ('FIND /N "::THIS IS START OF DISKPART BATCH COMMANDS::" %~dpnx0') DO SET More_offset=%%AFOR /F "tokens=2,7" %%A IN ('ECHO list disk^|diskpart^|FIND "B"') DO SET DP_disks=!DP_disks! %%AFOR %%A IN (%DP_disks%) DO (SET /A DP_Line#=%%A*3+%More_offset%FOR /F "skip=8 tokens=1,2,3 delims=: " %%B IN ('MORE +!DP_Line#! %~dpnx0^|diskpart.exe^|FIND /v /i "DISKPART"') DO (IF %%B.==Disk. SET DP_disk_sig_%%A=%%DIF %%B.==Volume. IF NOT %%C.==n.. IF NOT %%D.==Ltr. SET DP_disk_letters_%%A=!DP_disk_letters_%%A! %%DIF %%B.==Type. SET DP_disk_bus_%%A=%%C))SET DP_diskGOTO :EOF::THIS IS START OF DISKPART BATCH COMMANDS::select disk 0detail diskEXITselect disk 1detail diskEXITselect disk 2detail diskEXITselect disk 3detail diskEXITselect disk 4detail diskEXITselect disk 5detail diskEXITselect disk 6detail diskEXITCheers,jaclaz Edited December 10, 2008 by jaclaz
victor888 Posted December 9, 2008 Author Posted December 9, 2008 (edited) Very good example though it is language related.I use English mountvol.exe to test it. The result is very very good. Edited December 9, 2008 by victor888
jaclaz Posted December 9, 2008 Posted December 9, 2008 (edited) Yep, I tested it in English and Italian.The only "localized" part should be :IF %%B.==Disk. SET DP_disk_sig_%%A=%%DIF %%B.==Volume. IF NOT %%C.==n.. IF NOT %%D.==Ltr. SET DP_disk_letters_%%A=!DP_disk_letters_%%A! %%DIF %%B.==Type. SET DP_disk_bus_%%A=%%CIf users of other languages would post the corresponding for:DiskVolumen.Typeit should be possible to "widen the intended audience"....jaclazP.S.: Edit changed line to allow Italian and English Edited December 10, 2008 by jaclaz
victor888 Posted December 10, 2008 Author Posted December 10, 2008 Your idea of use batch file itself as diskpart script is wonderful.By the way has to point out, for vista, removable usb disk is also detected in diskpart.
victor888 Posted December 12, 2008 Author Posted December 12, 2008 A good command to turn localized system in to English: chcp 437
an3k Posted December 12, 2008 Posted December 12, 2008 If users of other languages would post the corresponding for:DiskVolumen.Typeit should be possible to "widen the intended audience"....From where do i get these informations? Can post them for a handful of languages.Thank for the script! I tested it and found a tiny bug. If the path to the file contains a space the script breaks up. Just place "" around %~dpnx0
jaclaz Posted December 12, 2008 Posted December 12, 2008 From where do i get these informations? Can post them for a handful of languages.Thank for the script! I tested it and found a tiny bug. If the path to the file contains a space the script breaks up. Just place "" around %~dpnx0Thanks for the reminder about the quotes: I am so used to use the "right" naming convention of paths without spaces that I always forget about other users habits. Maybe there is no need to make a multilingual check, try this version - where I tried to use actual "places" on lines to get the info.@ECHO OFFSETLOCAL ENABLEDELAYEDEXPANSIONSETLOCAL ENABLEEXTENSIONSFOR /F "tokens=1 delims=[]" %%A in ('FIND /N "::THIS IS START OF DISKPART BATCH COMMANDS::" "%~dpnx0"') DO SET More_offset=%%AFOR /F "tokens=*" %%A IN ('ECHO list volume^|diskpart^|FIND "Vol"^|FIND "B"') DO (SET LINE=%%ASET token1=!LINE:~7,2!SET token1=!token1: =!IF !token1! lss 10 SET token1=0!token1!SET token2=!LINE:~13,1!SET DP_Vol#!token1!=!token2!)SET DPFOR /F "tokens=2,7" %%A IN ('ECHO list disk^|diskpart^|FIND "B"') DO SET DP_disks=!DP_disks! %%AFOR %%A IN (%DP_disks%) DO (SET /A DP_Line#=%%A*3+%More_offset%SET /A Counter=0FOR /F "skip=8 tokens=* delims=" %%B IN ('MORE +!DP_Line#! "%~dpnx0"^|diskpart.exe^|FIND /v /i "DISKPART"') DO (Set /A Counter+=1IF !Counter!==1 CALL :Parse_Line DP_disk_sig_%%A %%BIF !Counter!==2 CALL :Parse_Line DP_disk_bus_%%A %%BIF !Counter! GTR 7 CALL :Parse_Line DP_disk_letters_%%A %%B))FOR /F "tokens=2* delims==" %%A IN ('SET DP_disk_letters_') DO SET DP_disk_letters=!DP_disk_letters! %%ASET DP_disk_letters=!DP_disk_letters: = !SET DP_diskSET ALLDRIVES=A B C D E F G H I J K L M N O P Q R S T U V W X Y ZSET BUSYDRV=SET FREEDRV=ECHO.:: List drive letters for physical drivesFOR /F "tokens=1 delims=\ " %%A IN ('MOUNTVOL /L ^| SORT ^| FIND ":\"') DO SET BUSYDRV=!BUSYDRV! %%A:: List drive letters for network drivesFOR /F "tokens=*" %%A IN ('NET USE ^|FIND ":"') DO (SET This_Drive=%%ASET This_Drive=!This_Drive:~13,1!SET BUSYDRV=!BUSYDRV! !This_Drive!SET NETDRV=!NETDRV! !This_Drive!)SET BUSYDRV=%BUSYDRV::=%:: Check which drive letters aren't used and list them as free drivelettersFOR %%A IN (%ALLDRIVES%) DO ( ECHO.%BUSYDRV% | FIND "%%A">nul IF ERRORLEVEL 1 (SET FREEDRV=!FREEDRV! %%A:&ECHO %%A: FREE) ELSE (ECHO %%A: BUSY)):: Remove leading commaSET FREEDRV=%FREEDRV::=%FOR /F "skip=1 tokens=1 delims= " %%A in ('reg query HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Disk\Enum /s ^|find "\"') do (SET ALLDisks=!ALLdisks! %%A)FOR %%A IN (%ALLDISKS%) DO (ECHO.%DP_disks% | FIND " %%A ">nul IF ERRORLEVEL 1 SET NOT_DP_Disks=!NOT_DP_Disks! %%A)FOR %%A IN (%BUSYDRV%) DO (ECHO.%DP_disk_letters% | FIND " %%A ">nul IF ERRORLEVEL 1 SET NOT_DP_Drives=!NOT_DP_Drives! %%A)SET NOT_SET BUSYSET FREESET NETGOTO :EOF:Parse_lineSET %1=!%1! %4GOTO :EOF::THIS IS START OF DISKPART BATCH COMMANDS::select disk 0detail diskEXITselect disk 1detail diskEXITselect disk 2detail diskEXITselect disk 3detail diskEXITselect disk 4detail diskEXITselect disk 5detail diskEXITselect disk 6detail diskEXIT
jaclaz Posted July 10, 2009 Posted July 10, 2009 Checking the "mbrfix" version.Something is simply NOT right.Preliminary:the "EXIT" in the first few lines is not a good idea (for people that run the batch from Command Prompt)first part of the output:All drive letters: C D M N O P Q R YMounted drive letters: C D M N O P Q RVirtual drive letters: YInternal hard disk 1 drive letter: CInternal hard disk 2 drive letter: DInternal hard disk 3 drive letter: {80cf88c6-8a34-11dd-813c-806d6172696f}R {80cf88c6-8a34-11dd-813c-806d6172696f}R {80cf88c6-8a34-11dd-813c-806d6172696f}R {80cf88c6-8a34-11dd-813c-806d6172696f}R {80cf88c6-8a34-11dd-813c-806d6172696f}R {80cf88c6-8a34-11dd-813c-806d6172696f}R {80cf88c6-8a34-11dd-813c-806d6172696f}R {80cf88c6-8a34-11dd-813c-806d6172696f}R {80cf88c6-8a34-11dd-813c-806d6172696f}RCd/dvd rom drive letters: MRemovalbe drive letters: N O P Q RA minor typo:Removalbe->Removablethe call to :vdrv creates havoc, as the %1 is "{80f886-8a34-11dd-813-806d6172696f}R"Mounted drive letters is NOT sorted and probably cause something queer, or some variable are left after batch competion, on second run:All drive letters: C D E F G H I J YMounted drive letters: C E D F G H I JVirtual drive letters: YInternal hard disk 1 drive letter: CInternal hard disk 2 drive letter: EInternal hard disk 3 drive letter: {80cf88c6-8a34-11dd-813c-806d6172696f}J {80cf88c6-8a34-11dd-813c-806d6172696f}J {80cf88c6-8a34-11dd-813c-806d6172696f}J {80cf88c6-8a34-11dd-813c-806d6172696f}J {80cf88c6-8a34-11dd-813c-806d6172696f}J {80cf88c6-8a34-11dd-813c-806d6172696f}J {80cf88c6-8a34-11dd-813c-806d6172696f}J {80cf88c6-8a34-11dd-813c-806d6172696f}J {80cf88c6-8a34-11dd-813c-806d6172696f}JCd/dvd rom drive letters: DRemovalbe drive letters: F G H I JIn :vdrv::vdrvset nk=!fulldrv:~%k%,1!if /i %1 neq !nk! ( set ordereddrv=!ordereddrv! %1¡ú!nk! mountvol %1: /d set viddrv=!viddrv! !totalvid:~%e%,38!!nk!)goto :eofthere is something strange, what the heck is ¡ú maybe some "extended characters" of some kind?The batch continues with a bunch of errors, too many to pinpoint at the moment, then I get this:ORDERED DRIVE LETTERS: {80f886-8a34-11dd-813-806d6172696f}Jí·D {80f886-8a34-11dd-813-806d6172696f}Jí·E {80f886-8a34-11dd-813-806d6172696f}Jí·F {80f886-8a34-11dd-813-806d6172696f}Jí·G {80f886-8a34-11dd-813-806d6172696f}Jí·H {80f886-8a34-11dd-813-806d6172696f}Jí·I {80f886-8a34-11dd-813-806d6172696f}Jí·J {80f886-8a34-11dd-813-806d6172696f}Jí·K {80f886-8a34-11dd-813-806d6172696f}Jí·L Eí·M Dí·N Fí·O Gí·P Hí·Q Ií·R Jí·Sand later on this:Internal hard disk 3 drive letter:Usb hard disk 1 drive letters: CUsb hard disk 2 drive letters: DCd/dvd rom drive letters: MRemovalbe drive letters: N O P Q Rand later on this:ORDERED DRIVE LETTERS: Mí·D Dí·E Ní·F Oí·G Pí·H Qí·I Rí·JThe diskpart version behaves a bit better, but still NOT WORKING (as well with the EXIT REMmed out):first run:C:\Downloaded\md5\diskpart>orderdrv_diskpart"orderdrv_diskpart.cmd" non è riconosciuto come comando interno o esterno, un programma eseguibile o un file batch.All drive letters: C D E F G H I J YMounted drive letters: C E D F G H I JVirtual drive letters: YInternal hard disk 1 drive letter: CInternal hard disk 2 drive letter: EInternal hard disk 3 drive letter:Cd/dvd rom drive letters: DRemovalbe drive letters: F G H I JORDERED DRIVE LETTERS: Eí·D Dí·EPremere un tasto per continuare . . .!nk! non atteso.Second run:C:\Downloaded\md5\diskpart>orderdrv_diskpart"orderdrv_diskpart.cmd" non è riconosciuto come comando interno o esterno, un programma eseguibile o un file batch.All drive letters: C D E F G H I J YMounted drive letters: C D E F G H I JVirtual drive letters: YInternal hard disk 1 drive letter: CInternal hard disk 2 drive letter: DInternal hard disk 3 drive letter:Cd/dvd rom drive letters: ERemovalbe drive letters: F G H I JDIRVE LETER ORDER IS CORRECT.Premere un tasto per continuare . . .!nk! non atteso.Again a small typo:DIRVE LETER ORDER IS CORRECT ->DRIVE LETTER ORDER IS CORRECTAs a reference this is the "right" set of mounted drives on the same machine (using ddlistw.cmd):C:\VSS>ddlistw3Drives by drive letter:c: 0,1 FIX \Volume{b0b284c3-8a33-11dd-8781-806d6172696f} \HarddiskVolume1d: 1,1 FIX \Volume{b0b284c4-8a33-11dd-8781-806d6172696f} \HarddiskVolume2e: x,x CDR \Volume{80cf88c2-8a34-11dd-813c-806d6172696f} \CdRom0f: 2,1 REM \Volume{5d3e8800-9c1f-11dd-8148-001fc6bb76ce} \Harddisk2\DP(1)0-0+5g: 3,1 REM \Volume{80cf88c3-8a34-11dd-813c-806d6172696f} \Harddisk3\DP(1)0-0+ah: 4,1 REM \Volume{80cf88c4-8a34-11dd-813c-806d6172696f} \Harddisk4\DP(1)0-0+bi: 5,1 REM \Volume{80cf88c5-8a34-11dd-813c-806d6172696f} \Harddisk5\DP(1)0-0+cj: 6,1 REM \Volume{80cf88c6-8a34-11dd-813c-806d6172696f} \Harddisk6\DP(1)0-0+dPremere un tasto per continuare . . .Drives by connection:c: 0,1 FIX \Volume{b0b284c3-8a33-11dd-8781-806d6172696f} \HarddiskVolume1d: 1,1 FIX \Volume{b0b284c4-8a33-11dd-8781-806d6172696f} \HarddiskVolume2f: 2,1 REM \Volume{5d3e8800-9c1f-11dd-8148-001fc6bb76ce} \Harddisk2\DP(1)0-0+5g: 3,1 REM \Volume{80cf88c3-8a34-11dd-813c-806d6172696f} \Harddisk3\DP(1)0-0+ah: 4,1 REM \Volume{80cf88c4-8a34-11dd-813c-806d6172696f} \Harddisk4\DP(1)0-0+bi: 5,1 REM \Volume{80cf88c5-8a34-11dd-813c-806d6172696f} \Harddisk5\DP(1)0-0+cj: 6,1 REM \Volume{80cf88c6-8a34-11dd-813c-806d6172696f} \Harddisk6\DP(1)0-0+de: x,x CDR \Volume{80cf88c2-8a34-11dd-813c-806d6172696f} \CdRom0jaclaz
victor888 Posted July 16, 2009 Author Posted July 16, 2009 Hi, Jaclaz.Thanks for your feed back first.The strange letter ¡ú is "→" I don't know if you can recognize it in IE.Do send me your registry value of "HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices". I must make a through check.I have to point out that the drive letter order of a fixed hard disk is obtained by their volume offsets size ascendingly.":sort" is the compare procedure, btw, IF command can compare hex values.
victor888 Posted August 1, 2009 Author Posted August 1, 2009 JaclazThough long time past since I have written above post, I think the problem you pointed out over and over. Finally, I think the problem comes from your ITALIAN xp system that is because of different system code.I found a strang letter from your feedback too--"Jí". I don't know what it is.I hope for a long time and again you could give your registry value of "HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices" for me to check.My batch files have been downloaded by many Chinese and no bugs emerge since my last revision (same as here attached).
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now