matze77 has asked for the wisdom of the Perl Monks concerning the following question:

Hello wise Monks!
I am searching for a way to script the change of the optical Drive of new machines to Drive Letter R:\ on Windows XP.
Anyone got a hint for me?.
To split the solution?:
a) First determine the optical drive (maybe through drivetype or something like that?)
b) Then change it if possible through scripting? It must not be necessary perl if any other solution is possible i am glad to use this too ...
Background (Another (Vendor) script which installs many programs which are needed in a given version is not starting if the driveletter is not set to R:\)

Update: Solved using diskpart
/Update
Thanks in Advance
MH
  • Comment on How to change the drive letter for a CD/DVD drive on Windows <b>Update: with a script</b>?

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

    The simplest way is to use subst. If the cdrom is configured as E: and you want it to appear as R: use

    subst r: e:\ ... subst r: /d rem When you've finshed

    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.

      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

        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.

        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.

Re: How to change the drive letter for a CD/DVD drive on Windows?
by SuicideJunkie (Vicar) on Dec 04, 2009 at 15:31 UTC

    Start -> settings -> control panel -> Admin tools -> computer management -> storage -> disk management(local) -> Rightclick a disk -> Change drive letter -> Change

    My condolences on the vendor. I thought that kind of absurdity died out in the early 90's