We help IT Professionals succeed at work.

How to assign the same drive letter to an external drive each time?

sasllc
sasllc asked
on
I have several customers on Win10 Pro that have two identical external hard drives.  When I plug them in the first time and format them, I also go into Disk Management and change the drive letter to K:  But as time goes on and they swap the drives each week, one or both no longer get set to K:, which makes the backup routine fail.

Is there a way to automate this process to insure they always get assigned as drive K?  (These is never a conflict--but the OS often assigns them to drive E: which is the next available.)  

If it cannot be automated, then I could consider some type of batch file to tell the user to run each week when they change out the drive.  I would need detailed guidance.  But what I cannot do with these non-high-tech customers is expect them to run Disk Management properly.  TIA
Comment
Watch Question

System Administrator
Distinguished Expert 2018
Commented:
If you are looking for some commands you can run to change the drive letter, here you are...
diskpart
list volume
select volume <number>
assign letter=K

Open in new window


But it's not always necessary to have the drive as a K:\ drive. Just from another discussion...

To get the same drive letter you'd have to use a script to do this on insertion of the drive into the computer. The problem is that Windows has disabled Autorun since late XP days. The other problem is that you're assuming the computers will all have the save drive letter available.


It is NOT necessary for the USB drive to have the same drive letter each time it is mounted in order to access the contents programmatically. There are ways to identify a drive and find the drive letter it is assigned and then reference it. Installers on any form of removable media have worked this way for decades.

You should look into relative paths, which allow shortcuts and files to refer to each other so long as they are only in the same position relative to each other, and where absolute paths may change.
Bill PrewTest your restores, not your backups...
Expert of the Year 2019
Top Expert 2016

Commented:
If you were to set a volume label on the external drive to something that would never change then you could use a small BAT file that they user manually ran after connecting the drive that would assign the drive to K.  Would that work, if so I could work up a starting BAT file for you.

My thinking is the BAT file would look at all drives and find the one with the volume label that matches what you set it to.  It would then check the assigned drive letter and if not K would assign it to K.


»bp

Author

Commented:
Using this approach:

diskpart
list volume
select volume <number>
assign letter=K

The <number> might change from time to time--true?  If so, my customers would not be able to handle something like this correctly.

I don't understand about the "relative paths", so I would need an example.  But note that I could use a UNC path rather than a drive letter if that would help, such as \\AcronisBackups\WS1\ to get to where I want to create the backup file.

If a batch file is best, having a sample would be greatly appreciated.  Note that when I first set up the two external drives for the customer I format them and give them both a volume name of "AcronisBackups".
Bill PrewTest your restores, not your backups...
Expert of the Year 2019
Top Expert 2016

Commented:
It doesn't look easy to create a BAT file that re-assigns to K: if it is a different letter.  It used to be that diskpart wasn't too hard to script, you could pipe commands into it, but that doesn't seem to work any more.  There is also a /S option to process a text file of commands, but that isn't working for me either.  Not sure if UAC is interfering, since it's asking to elevate privs.

At any rate it's looking more complex than I thought, which typically means it won't be as reliable when implemented.  I suspect there is something easier that could be worked up in Powershell, but I'm not a master there yet...


»bp
Hello ThereSystem Administrator
Distinguished Expert 2018

Commented:
A few years ago I needed the same... Just reserve the specific letter for my USB drive. So I assigned the letter in Disk Management and I've never had an issue with this since then. If I connect the drive, it's been getting the same letter for years now.

Since this is not working for you, I suggest to use the third party solution - USB Drive Letter Manager (link here).
Bill PrewTest your restores, not your backups...
Expert of the Year 2019
Top Expert 2016
Commented:
USBDLM looks very interesting, and quite reasonably priced considering the wealth of capability...

There is of course a large downside to that in that it requires a service to be installed on each PC that will be mounting the USB drives, but that may only be a couple of computers in this case so manageable.

Of note from the same author I saw "ReMount V2.1 - reassigning mountpoints (change drive letters)"  on the page below.  This might be more easily incorporated into a BAT script than DISKPART would have been so might be worth checking out.  And if you can place the BAT and this small util on a shared folder location then there's really nothing to deploy to the individual machines.  Just  a thought...



»bp