By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,353 Members | 1,237 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,353 IT Pros & Developers. It's quick & easy.

How to change a drive letter with

P: n/a
Kind people on this discussion group have previously helped me to dynamically
identify CD rom drives etc at runtime using objects in

Dim query As New System.Management.ManagementObjectSearcher("SELECT * From
Dim queryCollection As System.Management.ManagementObjectCollection =

For Each mo As System.Management.ManagementObject In queryCollection
Select Case Integer.Parse(mo("DriveType").ToString())

Case 2 'removable drives

Case 3 'Local drives
MsgBox("Logical Drive " & mo("DeviceID").ToString)

Case 4 'Network drives
MsgBox("Network Drive " & mo("DeviceID").ToString)

Case 5 'CD rom drives

MsgBox("CD Rom Drive " & mo("DeviceID").ToString)

End Select
++++++++++++++++++++++++++++++++++++++++++++++++++ +++

Can I use these objects to change the drive letter of one of these logical

ie in the routine above
Case 3 'Local drives
MsgBox("Logical Drive " & mo("DeviceID").ToString)

If mo("DeviceID").ToString = "S:" Then
mo.SetPropertyValue("DeviceID", "T:")
MsgBox("local Drive" & mo("DeviceID").ToString)
End If
The deviceID is changed in the ManagementObject at runtime but this does not
manifest itself as a change in the drive letter.

I would also like to be able to create and destroy mapped network drives on
the fly.

the objects in the namspace seem to me to be very abstract
and non-intuitive to use. I would be interesed in understanding them better.
So if anyone has a tutorial on this subject that starts at a suitably newbie
level for my simple brain to understand then I would be gratefull.

Much thanks

Jul 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.