Announcement

Collapse
No announcement yet.

How to change drive letter Daemon Tools without GUI

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to change drive letter Daemon Tools without GUI

    Hi everybody,

    I signed up to this forum so I can share my solution to change the Daemon Tools drive letter without user interference.

    Because we have a lot of different workstations that all have to use the same drive letter and I couldn't find an exact solution, I found and edited the following VB script to work with Daemon Tools.

    On Error Resume Next

    'Device IDs
    DeviceID1 = "DTSOFTBUS&REV1\DTCDROM&REV1\1&79F5D87&0&00"
    DeviceID2 = "DTSOFTBUS&REV1\DTCDROM&REV1\1&79F5D87&0&00"
    DeviceID3 = "DTSOFTBUS&REV1\DTCDROM&REV1\1&79F5D87&0&00"
    DeviceID4 = "DTSOFTBUS&REV1\DTCDROM&REV1\1&79F5D87&0&00"
    DeviceID5 = "DTSOFTBUS&REV1\DTCDROM&REV1\1&79F5D87&0&00"

    strComputer = "."
    Dim nRtn, WshShell
    Set WshShell = WScript.CreateObject("WScript.Shell")
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    Set colItems = objWMIService.ExecQuery("Select * from Win32_CDROMDrive")

    Dim driveFound
    driveFound = False

    For Each objItem in colItems
    If driveFound Then Exit For
    Select Case (objItem.DeviceID)
    Case DeviceID1
    x = ChgDrv ("Y:", objItem.Drive)
    driveFound = True
    Case DeviceID_2
    x = ChgDrv ("Y:", objItem.Drive)
    driveFound = True
    Case DeviceID3
    x = ChgDrv ("Y:", objItem.Drive)
    driveFound = True
    Case DeviceID4
    x = ChgDrv ("Y:", objItem.Drive)
    driveFound = True
    Case DeviceID5
    x = ChgDrv ("Y:", objItem.Drive)
    driveFound = True
    End Select
    Next


    Function ChgDrv(Drive, theDrive)
    If theDrive <> Drive Then

    'Create File
    strFilename = "chgdrv" & Left(Drive,1) & ".txt"
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.CreateTextFile(strFilename)
    objFile.Close

    'Write Data to File
    Set objFile = objFSO.OpenTextFile (strFilename, 2)
    objFile.WriteLine "select volume " & theDrive
    objFile.WriteLine "assign letter=" & Drive
    objFile.WriteLine "exit"
    objFile.Close

    'Run Diskpart calling the script just created
    strRun = "diskpart /s " & strFilename
    nRtn = wshShell.Run(strRun, 2 , True)

    'Delete File
    objFSO.DeleteFile(strFilename)
    Else
    WScript.Echo "Drive is already in use " & Drive
    End If
    End Function
    This script changes the current drive letter to Y:

    This can easily be changed to any other drive letter by editing the letter Y: to any other drive letter that is not in use.

    As far as I know Daemon Tools always uses the deviceID DTSOFTBUS&REV1\DTCDROM&REV1\1&79F5D87&0&00, but if this ever changes it can easily be retrieved by opening msinfo32.exe and expand 'Components' > 'CD-ROM'.
    The Device ID's in the VB script should be made similar to the PNP Device ID information in the Microsoft system information application.
Working...
X