Click here to Skip to main content
13,868,372 members
Click here to Skip to main content
Add your own
alternative version


4 bookmarked
Posted 24 Jan 2018
Licenced GPL3


, 26 Jan 2018
Rate this:
Please Sign up or sign in to vote.
Workaround for changing drive letters in Windows when using multiple external drives

Introduction (The Project in Less than 30 40 47 Words)

Recently, I was facing a problem I never thought could be an issue. If you have a pool of hard discs that you connect to a computer, the drive letter seems not to be constantly the same.

Here is a practical approach to handle it.

The Code


The Problem in Detail

When you connect different hard discs (in my case by eSATA) and you want them to always have the same drive letter, you face the problem that the drive letter is not constantly the same. It seems to be a problem to have (in my case eight) drives out of a pool of 16 to have the same drive letter when they are connected. This could be a problem if you shared the drive, e.g., for using the drive as a backup target.

I’m not talking about situations where the drive letter is used by another drive or multiple drives are connected. I am talking about a scenario where two drives out of a pool of 16 are connected the same time. (Mo – The media and 4 Fr media sets.)

The Idea

I guessed Windows is putting all connected drives to a list when I manually assign a custom drive letter to it. This works in my tests as long as you always assign different drive letters. If you have two drives, you want to have the K letter for example, it works only for the last manually assigned drive. If you connect the other one, it gets the first free drive letter. (Tested on Windows Server 2012 R2, Windows 10 Pro.)

So, if Windows is not ”willing” to track the drives, we have to put them on our own list.

All you need now is the drives guid, that every drive (& volume) has and the target drive letter.

The Result

With a little WMI magic, we can iterate through all connected drives (locally, USB, SATA) and change or remove the drive letter.

Putting all the requirements with the magic together will bring us to the concept to have a small application that reads a list of drives from a text file, remove any eventually already used drive letter and finally reassign all drive letters based on the lists data.

Sounds simple, huh?

How to Use It

First of all, the application can only work when run as administrator because standard users are not allowed to change the drive letter.

When the application is started without a parameter, it will list up all currently connected (they actually don’t need to have a drive letter) drives and volumes to the screen and also to a text file called “CurrentDrives.txt” in the application directory.

The written text file looks like this:

In my case, you see that my c drive is connected and the letter p is assigned to the connected USB thumb drive.

As you notice, my system as also three partitions (or volumes) that currently do not have any assigned drive letters. These are the recovery partition(s) and the hidden Windows partition, which Windows creates at setup.

To make the application change the drive letter, you have to create a text file which contains the drive guid followed by a TAB and followed by the drive letter it should get. (You can copy and paste it out of the just generated text file).

If I would like to change the drive letter of the thumb drive from p to t, this is the file:

Please have in mind, you need to be administrator to change the drive letter !

What’s Next, Further Thoughts

In my case, I use the application as a scheduled task at a fixed time. But what I could think about is, to run it once an external media is connected. This could be bound to the occurrence of an event in the task scheduler. The source is also added, feel free to play around.


As a side project, I prepared another tool called DriveLetterMaker, based on the idea of snoopy001 here in the comments section. (With a little update form my side...)

The idea behind DriveLetterMaker is that the device that you connect contain a textfile called Make_Me_Drive_X.txt which defines which drive letter it should be. When the tool runs, it removes any existing drive letter for that column and assigns the one from the filename. The content of the text file is not read, so it doesn't matter at all. This will reduce the handling effort with the long list of volume guids.

Here are the files:


  • 24.01.2018: Release version 1.00
  • 26.01.2018: DriveLetterMaker version 1.00 added


This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


About the Author

Germany Germany
No Biography provided

You may also be interested in...

Comments and Discussions

QuestionI had a similar problem Pin
Roger50029-Jan-18 12:43
memberRoger50029-Jan-18 12:43 
AnswerRe: I had a similar problem Pin
FiegeU7-Feb-18 11:41
memberFiegeU7-Feb-18 11:41 
QuestionUsing a txt file to set drive letter isn't a good idea Pin
ObiWan_MCC29-Jan-18 4:16
memberObiWan_MCC29-Jan-18 4:16 
AnswerRe: Using a txt file to set drive letter isn't a good idea Pin
FiegeU7-Feb-18 11:46
memberFiegeU7-Feb-18 11:46 
GeneralRe: Using a txt file to set drive letter isn't a good idea Pin
ObiWan_MCC8-Feb-18 4:50
memberObiWan_MCC8-Feb-18 4:50 
QuestionFixed Drive letter Pin
Merlin8725-Jan-18 9:18
memberMerlin8725-Jan-18 9:18 
AnswerRe: Fixed Drive letter Pin
FiegeU25-Jan-18 11:58
memberFiegeU25-Jan-18 11:58 
GeneralRe: Fixed Drive letter Pin
Merlin8725-Jan-18 22:54
memberMerlin8725-Jan-18 22:54 
GeneralRe: Fixed Drive letter Pin
FiegeU25-Jan-18 23:19
memberFiegeU25-Jan-18 23:19 
QuestionNice idea Pin
snoopy00125-Jan-18 3:56
membersnoopy00125-Jan-18 3:56 
AnswerRe: Nice idea Pin
FiegeU25-Jan-18 12:11
memberFiegeU25-Jan-18 12:11 
GeneralRe: Nice idea Pin
snoopy00125-Jan-18 13:07
membersnoopy00125-Jan-18 13:07 
GeneralRe: Nice idea Pin
FiegeU26-Jan-18 0:33
memberFiegeU26-Jan-18 0:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web05 | 2.8.190214.1 | Last Updated 26 Jan 2018
Article Copyright 2018 by FiegeU
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid