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?
Batch Drive Letter Assignment
Moderator: DosItHelp
Re: Batch Drive Letter Assignment
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.
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.
Re: Batch Drive Letter Assignment
If you are running the bat files from the USB stick then this will help:
Code: Select all
@echo off
echo %~d0
pause