how to mount a partition to a folder from commande line?

Posted on

QUESTION :

i use NTFS folders to mount my external drives.

I have this bug : windows cannot make the difference between all drives from the same model.

For example, let say i have 2 WD 2To, one for photos and another one for videos.

If i mount one WD 2To in c:mntphotos, then next time i connect a WD 2To, no matter if it’s the photos or videos one, it’s going to be mounted automatically in c:mntphotos.

I don’t have problems with different drives, for example, WD 2To and Seagate 2To, because for windows it’s 2 differents drives.

I think (not tested), this bug occurs too with mapped drives letters.

This is why i try to found a workaround for this.

Is this possible to have a script to mount my drive to the correct folder ?

Let’s say i connect my photos drive, i launch a .bat script to mount it to the correct folder.

Something like that :

list drives connected to the system (diskpart ?)
for each drives
  is it photos drive ?
  if yes
    delete the mount point (letter or folder) if there is one
    mount it to c:mntphotos
  is it videos drive ?
  if yes
    delete the mount point (letter or folder) if there is one
    mount it to c:mntvideos

It could be a .bat script but if you have ressources to do this in c#, i could use that too.

ANSWER :

Solution 1 :
access files directly from the path given by montvol command
?Volume{a7b93d18-7f27-47ae-8174-fc1f6680b7f7}pathtofolderfile.txt

Solution 2 :
USB Drive Letter Manager
https://www.uwe-sieber.de/usbdlm_e.html

this solution need to put a ini file in the root of the drive

USBDLM will read this file and correct the mount point if it’s incorrect

Leave a Reply

Your email address will not be published. Required fields are marked *