How To Change The CD/DVD Drive Letter? #Batch
Category : Batch
Author: Frank Peter (97 Articles)
UPDATE Feb 16, 2017: For a PowerShell version that uses the approach below go to RemountCompactDisk.ps1
The cmd.exe command line below uses mountvol.exe in order to delete the old and to set the new drive letter assignment (where E: represents the old and Z: the new drive letter):
FOR /F %V IN (
'mountvol.exe E: /L'
) DO (
mountvol.exe E: /D
mountvol.exe Z: %V
The FOR /F command parses a mountvol command that returns the CD-ROM drive’s volume name. The volume name looks like this:
If FOR /F successfully determines a volume name it executes two mountvol commands, the first one deletes the current drive letter assignment the seconds one sets the new drive letter assignment (using the volume name).