Batch Drive Letter Assignment

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
cooskin
Posts: 1
Joined: 08 Jul 2013 13:39

Batch Drive Letter Assignment

#1 Post by cooskin » 08 Jul 2013 13:44

Ok, I am good at some things but coding a batch file is not one of them. I am trying to create a batch file that will allow me to assign a drive letter to my USB regardless of which computer I am on. I have been successful at using some pieces of scripts I found online but they only work on my Win7 machine. I have two Win8 machines and a Win7. I need these to assign to the same drive regardless of which machine I use. I try and use the same script from 7 to 8 and it's a no go.

Can someone please help me out?

penpen
Expert
Posts: 2009
Joined: 23 Jun 2013 06:15
Location: Germany

Re: Batch Drive Letter Assignment

#2 Post by penpen » 08 Jul 2013 16:12

As far as i know this is imposssible to assign a static letter for a removable device:
You only can make it less probable that the drive letter will be reassigned.
The cause is simple:
You can have more removable drives than letters, but they are not connected at the same time.

The drive letter assignement can be done in the "Computer Management" console.
On the left side there should be a tree node named "Storage" with a subnode "Disk Management".
If you have connected the device to the pc you can reassign the drive letter.
You should choose a higher drive letter, as an assignment can time out.
This should take days or weeks, but it will for sure if you don't connect this device to pc often enough.
And the next removable device connecting to this pc gets this drive letter, if no lower letter is free to use.
You additionally should not use drive letters that are used by network drives, as they have a higher "assign-priority".

You wish to write a batch, so i assume you may change some registry keys.
I don't know the key that windows 8 uses for such things, but you may download a tool from Microsoft somewhere on this page, with that you can find this key:
http://technet.microsoft.com/en-US/sysinternals
I assume it is under the file and disk utilities (i am not sure), but its name is:
Process Monitor
Maybe this site has been moved then you should search on the Microsoft site for "sysinternals" or "process monitor".
And i additionally think, as this is produced by Microsoft, that there is a version available that works under windows 8, but i'm not sure.

Assumed that you can use "process monitor" under windows 8:
With this tool you can watch the registry activity (and some other things, that you should deactivate, as you are only interested in registry keys).
Start registry monitoring with this tool and then change the drive letter assignment using the "Disk Management" tool within the "Computer Management" console.
Then stop monitoring, and search for the key (or keys) that have been changed. Maybe you do it some more times, to exclude other changes.
Normally there is only one registry key for such things, and you can google for the found results, so you can confirm this is the right key (or disprove it).

Hope this helps, even if this is more a guide and not a batch.

penpen

Edited: I hope The "Computer Management" console with the "Disk Management" is still part of the system using Windows 8.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Batch Drive Letter Assignment

#3 Post by foxidrive » 09 Jul 2013 01:15

If you are running the bat files from the USB stick then this will help:

Code: Select all

@echo off
echo %~d0
pause

Post Reply