How To Change The CD/DVD Drive Letter? #Batch

  • 2

How To Change The CD/DVD Drive Letter? #Batch

Tags :

Category : Batch

Line Break

Author: Frank Peter (94 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):

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).


2 Comments

ServerGuy

December 30, 2016 at 7:18 pm

what is old cd rom letter is not E, will it dynamically sense the letter and assign a user defined letter

    Frank Peter

    February 16, 2017 at 8:28 am

    No, the example just demonstrates the concept with hard coded drive letters. It’s possible to make it more flexible though

Leave a Reply

*