I have been having some problems with an external Sata hard drive on my PC. I assign it a specific letter, but when I reboot, the drive does not maintain its letter. The drive itself is new, but I also had the same problem with another drive.
If this problem can’t be fixed, I would like to create a batch file to assign the drive a specific letter quickly and automatically rather than doing it manually through ‘Computer Management’.
Does anyone know the wording, which I should use in the batch file? Any help would be appreciated.
JohnB
Assign Drive Letter by Batch File
Moderator: DosItHelp
Re: Assign Drive Letter by Batch File
I believe you could use DISKPART or MOUNTVOL.
Re: Assign Drive Letter by Batch File
johnbil wrote:I have been having some problems with an external Sata hard drive on my PC. I assign it a specific letter, but when I reboot, the drive does not maintain its letter.
Is it USB? Try setting the drive to a higher letter in an area that will not be reached with other devices, using Disk Management.
S: or even Z: etc.
Re: Assign Drive Letter by Batch File
I tried DISKPART, but couldn't figure out how to input the criteria at the prompt via the batch file.
Assigning Z: as the drive letter seems to have the letter maintained in the next session.
Thanks for the advice guys.
Assigning Z: as the drive letter seems to have the letter maintained in the next session.

Thanks for the advice guys.
Re: Assign Drive Letter by Batch File
johnbil wrote:Assigning Z: as the drive letter seems to have the letter maintained in the next session.![]()
What happens with USB is that the first available drive letters get shuffled as USB devices get added, removed, and changed.
Nothing remains stable wrt those drive letters.
Re: Assign Drive Letter by Batch File
Hi,
I had the very same problem on a disk that should appear as E:
Here is what I do automatically upon the computer start:
if exist E:\ goto :eof
echo select volume 3 >%tmp%\script.txt
echo assign letter E >>%tmp%\script.txt
diskpart /s %tmp%\script.txt rem run diskpart with the correct answers
So basically:
if drive is here, exit
generate a response file for diskpart
run diskpart with the correct answers
I had the very same problem on a disk that should appear as E:
Here is what I do automatically upon the computer start:
if exist E:\ goto :eof
echo select volume 3 >%tmp%\script.txt
echo assign letter E >>%tmp%\script.txt
diskpart /s %tmp%\script.txt rem run diskpart with the correct answers
So basically:
if drive is here, exit
generate a response file for diskpart
run diskpart with the correct answers