victor888

[Updated on Feb. 27. 2011] ordering messed drive letter batch file

58 posts in this topic

1. Can fix flash disk driver letter:

Seletion to fix flash disk driver letter:

set USBDRV=U

"U" is your flash drive letter to be fixed, you may change it as your need.

For FIXED USB DISK (usb hard disk or fixed type usb disk) this selection nas no meaning.

Also it is not fit to the condition that more than 1 flash disk exists.

Do be sure that flash USB drive letter is not confilict with any other existing drive letter.

1. support WIN7 (WIN7 PE).

2. support VHD disk recognition.

3. code optimized.

4. add Automated run selection.

selection for automated run

 set AUTO=n (default is n, which means no intercourse needed. if AUTO was set to y, means automatic mode is opened.)

===

Special thanks to Jaclaz.

===

Function: order messed drive letters caused by, for example, installing xp from usb (removabe or hard disk), startting pe from usb etc.

Win command used: reg (to query information from registry), find (combine with other command), wimc (to get all drive letters. For PE, all drive letters are find from registry ), mountvol (to change drive letters), diskpart.exe (to get disk drive letters, only for diskpart version)

Workround: This batch work under winpe and winnt systems(XP,2k3,vista and WIN7).

Note:

1. Don not run subst or net use prior to running it.

mbrfix.rar

Edited by victor888
0

Share this post


Link to post
Share on other sites

If you have any difficulties in understanding this batch, just let me know. I will give details.

Edited by victor888
0

Share this post


Link to post
Share on other sites
Jaclaz try this again.

Will do, thanks. :)

...and let you know ....;)

jaclaz

P.S.: Quicly tested, it doesn't work (properly) for me, though I see it as a great improvement over the "old" one :)

C:\Downloaded\victor888>regorderdrv
all drive letters: C D E G H I J K L M N R
mounted drive letters: i C E D R N G H I J K L M
virtual drive letters:
internal hard disk 1 drive letter: C

Errore: impossibile trovare la chiave del Registro di sistema o il valore specificato

Errore: impossibile trovare la chiave del Registro di sistema o il valore specificato
usb hard disk 1 drive letters: E
usb hard disk 2 drive letters: J K L M
floppy drive letters:
cd/dvd rom drive letters: D
remmovalbe drive letters: i R N G H I

Legend:

Errore: impossibile trovare la chiave del Registro di sistema o il valore specificato

=

Error cannot find specified Registry key or value

Real situation:

1) internal (SATA) drives: C:, E: :(

2) CD D: :)

3) USB hard disk J: K: L: M: :)

4) Removable (SD card reader, 4 slots) G: H: I: N:

5) Virtual disk (removable - Perioft demo driver) R:

Edited by jaclaz
0

Share this post


Link to post
Share on other sites

Ok, mounted drive letter "i" is incorrect.

Please show me the result of MOUNTVOL.EXE.

For drive letter R:, it must have has a volume id and been recognized as removable device.

Edited by victor888
0

Share this post


Link to post
Share on other sites

OK, I will get mount point from registry, not from MOUNTVOL.EXE and make optimization.

0

Share this post


Link to post
Share on other sites

VERY GOOD WORK! :)

Still something that must be taken into account (I know I am picky, but that should be the right attitude for "testers") ;):

regorderdrv
All drive letters: C D E F G H I N R X
Mounted drive letters: C E D R N G H I
Virtual drive letters: FX
Internal hard disk 1 drive letter: C
Internal hard disk 2 drive letter: E
Internal hard disk 3 drive letter: {80cf88c6-8a34-11dd-813c-806d6172696f}I {80c
f88c6-8a34-11dd-813c-806d6172696f}I {80cf88c6-8a34-11dd-813c-806d6172696f}I {80c
f88c6-8a34-11dd-813c-806d6172696f}I
Cd/dvd rom drive letters: D
Remmovalbe drive letters: R N G H I

subst
X:\: => C:\WINPE BUILDER\X

I added a SUBST drive, just to see how it would behave. :whistle:

C: and E: are Internal Fixed Disks

D: is CD-ROM

F: is a IMDISK Virtual Disk

X: is the SUBSTed drive

R: is the Perisoft Virtual Disk

N: G: H: I: are partitions on external USB

A small typo:

Remmovalbe Removable drive letters: R N G H I

The listed virtual drive letters miss a separator.

I would use the "normal" convention of colons and the comma as separator, like:

All drive letters: C:, D:, E:, F:, G:, H:, I:, N:, R:, X:

I will try a combo of more Virtual Disks and post results....;)

jaclaz

P.S.:

@ALL

If you want to test this batch, add a GOTO :EOF here:

GOTO :EOF

::remove system drive letters and volume ids

so that drive letters are NOT re-ordered

Edited by jaclaz
0

Share this post


Link to post
Share on other sites

Perhaps I am lost in registry searching.

This CMD will take usb hard disk as internal hard disk if booted with pe on usb hard disk and drive letter c belongs to it.

Sometimes when boot pe, no "diskperipheral " value found in registy which reselts to no internal hard disk found.

Edited by victor888
0

Share this post


Link to post
Share on other sites

No joy yet (version dated 30/11/2008). :(

regorderdrv
All drive letters: C D E F G H I J K L M N O
Mounted drive letters: C D I J K L M N E G H O F
Internal hard disk 1 drive letter: C
Usb hard disk 1 drive letters: D
Usb hard disk 2 drive letters: E G H O
Cd/dvd rom drive letters: I
Remmovalbe drive letters: J K L M N F

D: is second internal hard disk.

E: G: H: O: are first (and only) USB HD.

There is no distinction among the various Remmovalbe Removable drives:

F: is a USB stick

J: is Perisoft Virtual SCSI disk

K: L: M: N: are USB Card Reader Combo.

You "changed the rules" ;) of the game, however. :whistle:

The point was - at least in my mind - to use no external utility, otherwise most of the fun would be lost. :ph34r:

It will take me some time to check the batch code, will let you know If I find where the problem might be....

Cheers,

jaclaz

0

Share this post


Link to post
Share on other sites

Thank you very much, you poitns its bug, second hard disk wrong.

I disklike break the rule too.

I have to use dispart to replace mbrfix.

a revised version will coming soon.

Edited by victor888
0

Share this post


Link to post
Share on other sites

I like to play along the rules of the "game" ;)

Try the attached. :whistle:

A bit slowish, needs polishing and betterings, but maybe we're getting somewhere :unsure:. (only REG.EXE and MOUNTVOL.EXE is used, NO temporary files)

Cheers,

jaclaz

listdrives.zip

0

Share this post


Link to post
Share on other sites

Well done.

A:
C: 0,0 IDE Fixed
D: 0,1 IDE Fixed
E: 0,2 IDE Fixed
F: 0,3 IDE Fixed
G: 0,4 IDE Fixed
H: 0,5 IDE Fixed
I: 0,6 IDE Fixed
J: 0,7 IDE Fixed
K: 0,8 IDE Fixed
L: IDE CD-ROM
M: Fixed
N: 1,0 USB Removabl
O: 3,0 USB Removabl
P: 4,0 USB Removabl
Q: 5,0 USB Removabl
R: Fixed

The result is correct.

One problem is it doesn't tell where are USB hard disk drive letters type (M: R:). Only give FIXED drive letter.

Addition: for winpe, sometimes no item under DISKPERIPHERAL, so no signature found.

Anoter thing, this batch doesn't arrange drive letters according to volume order.

I should further examine your code.

thanks.

Edited by victor888
0

Share this post


Link to post
Share on other sites

It works for my USB external hard disk:

C: 0,0 IDE	  Fixed
D: 1,0 IDE Fixed
E: 7,0 USB Fixed
G: 7,1 USB Fixed
H: 7,2 USB Fixed
I: IDE CD-ROM
J: 2,0 SCSI Removable
K: 3,0 USB Removable
L: 4,0 USB Removable
M: 5,0 USB Removable
N: 6,0 USB Removable
O: 7,3 USB Fixed

(letters E: G: H: O: ) :unsure:

Try using the /v switch and post output.....

About ordering, at the end of the batch "main", after:

FOR /F "Tokens=2 delims==" %%? IN ('SET LDrive') DO ECHO %%?

and before:

GOTO :EOF

These two lines:

ECHO.

FOR /F "Tokens=2 delims==" %%? IN ('SET LDrive ^|SORT /+14') DO ECHO %%?

Output becomes this ;):

C: 0,0 IDE	  Fixed
D: 1,0 IDE Fixed
E: 7,0 USB Fixed
G: 7,1 USB Fixed
H: 7,2 USB Fixed
I: IDE CD-ROM
J: 2,0 SCSI Removable
K: 3,0 USB Removable
L: 4,0 USB Removable
M: 5,0 USB Removable
N: 6,0 USB Removable
O: 7,3 USB Fixed

I: IDE CD-ROM
C: 0,0 IDE Fixed
D: 1,0 IDE Fixed
J: 2,0 SCSI Removable
K: 3,0 USB Removable
L: 4,0 USB Removable
M: 5,0 USB Removable
N: 6,0 USB Removable
E: 7,0 USB Fixed
G: 7,1 USB Fixed
H: 7,2 USB Fixed
O: 7,3 USB Fixed

We could give a "fake" physical drive number to CD-ROM(s) to alter the order.

PE is a different thing....:unsure:

Also I need to know how would a SATA CD/DVD behave....:unsure:

And however I am not so sure that entries in Services\Disk\Enum are the same as the output of WMIC.....this needs to be checked thoroughfully.

EDIT:

Checked, and unfortunately they do not correspond :( a similar batch using WMI gives different results:

C: 0_0 IDE	  Fixed [HD]	  MAXTOR STM3320820AS
D: 1_0 IDE Fixed [HD] MAXTOR STM3320820AS
E: 3_0 USB Fixed [HD] SAMSUNG HD320KJ USB Device
G: 3_1 USB Fixed [HD] SAMSUNG HD320KJ USB Device
H: 3_2 USB Fixed [HD] SAMSUNG HD320KJ USB Device
J: 2_0 SCSI Removable [HD] Perisoft Virtual Disk SCSI Disk Device
K: 4_0 USB Removable Generic USB SD Reader USB Device
L: 5_0 USB Removable Generic USB CF Reader USB Device
M: 6_0 USB Removable Generic USB SM Reader USB Device
N: 7_0 USB Removable Generic USB MS Reader USB Device
O: 3_3 USB Fixed [HD] SAMSUNG HD320KJ USB Device

Additionally mountvol does not detect IMDISK Virtual Disks :(:

http://www.boot-land.net/forums/index.php?showtopic=3909

I guess we need to find out how to manage correctly the entries in \DosDevices and forget about mountvol.

The FREEDRV I wrote some time ago could be part of the solution...I will have to study it (I am getting old an cannot even say if it used mountvol or not....):

http://www.911cd.net/forums//index.php?sho...=21965&st=6

EDIT:

Checked, no way to detect IMDISK volumes through Mountvol or Registry....

jaclaz

P.S.: On the machine I tried it I don't have a floppy, thus it is not "detected" at all (there is NO code for it), but I think anyway that it would be advisable to simply "exclude" A: and B: from the mountvol command, you aren't going to change those drive letters, are you?

Edited by jaclaz
0

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.