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

MS DOS

1

2

3

4

5

6

FOR/F%VIN(

'mountvol.exe E: /L'

)DO(

mountvol.exeE:/D

mountvol.exeZ:%V

)

The FOR /F command parses a mountvol command that returns the CD-ROM drive’s volume name. The volume name looks like this:

MS DOS

1

\\?\Volume{1d926311-403a-11d9-94c8-806d6172696f}\

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