in reply to Re: How to change the drive letter for a CD/DVD drive on Windows?
in thread How to change the drive letter for a CD/DVD drive on Windows <b>Update: with a script</b>?

Thank you for your reply.
That wont do the trick. It has to be permanent.
There are reboots in the other script.
And is the "Policy" so I hoped there is an automatic way ...
<Update> Maybe i could find the registry keys and parse them to see if it is a hard drive or an optical drive, so i dont change accidently the hard-drives letter which could be fatal ...
I think i found the registry key (it is already changed to Driveletter R in the example:)
(HKLM\SYSTEM\MountedDevices):

"\\DosDevices\\R:"=hex:5c,00,3f,00,3f,00,5c,00,49,00,44,00,45,00,23,00 +,43,00,\ 64,00,52,00,6f,00,6d,00,54,00,53,00,53,00,54,00,63,00,6f,00,72,00,70 +,00,5f,\ 00,43,00,44,00,44,00,56,00,44,00,57,00,5f,00,54,00,53,00,2d,00,48,00 +,36,00,\ 35,00,33,00,46,00,5f,00,5f,00,5f,00,5f,00,5f,00,5f,00,5f,00,5f,00,5f +,00,5f,\ 00,5f,00,5f,00,5f,00,5f,00,5f,00,5f,00,4c,00,45,00,30,00,37,00,5f,00 +,5f,00,\ 5f,00,5f,00,23,00,35,00,26,00,32,00,36,00,37,00,39,00,34,00,34,00,66 +,00,62,\ 00,26,00,30,00,26,00,30,00,2e,00,31,00,2e,00,30,00,23,00,7b,00,35,00 +,33,00,\ 66,00,35,00,36,00,33,00,30,00,64,00,2d,00,62,00,36,00,62,00,66,00,2d +,00,31,\ 00,31,00,64,00,30,00,2d,00,39,00,34,00,66,00,32,00,2d,00,30,00,30,00 +,61,00,\ 30,00,63,00,39,00,31,00,65,00,66,00,62,00,38,00,62,00,7d,00
In cleartext it reads:
\ ? ? \ I D E # C d R o M T S S ... Any Idea how to parse this have i use to parse the hex valuese? <br>?
</Update>

As a last resort i could do it the "graphical way" using autoit or some Win32:GUI Module but I think there could be errors this way ...
Thanks
MH

Replies are listed 'Best First'.
Re^3: How to change the drive letter for a CD/DVD drive on Windows?
by BrowserUk (Patriarch) on Dec 04, 2009 at 15:10 UTC

    Take a look at the diskpart command. Specifically, the assign subcommand and the /s scripting switch.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

      Thx. That was it. Since DVD/CD Drives seem to be volume 0 it is as simple as:
      diskpart /s script.txt

      script.txt: select volume=0 assign letter=R list volume

      Thanks
      MH
      You saved my day ...

        You might want to at least consider the possibility of multiple drives or other volume assignments:

        #! perl -slw use strict; my @vols = split "\n", `diskpart /s listvol.txt`; print for @vols;

        Where listvoe.txt contains:

        list volume

        Will get you the volume list. You can then grep on /ROM/ and tease the line(s) apart to get the volume number.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.
Re^3: How to change the drive letter for a CD/DVD drive on Windows?
by marto (Cardinal) on Dec 04, 2009 at 14:28 UTC

    You may be able to set the appropriate registry key once, obviously this would need to be done as a user with such privilages. I'm sure if you search Google you'll find someone has done this before.