473,320 Members | 2,193 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to: Change a drive letter

Kind people on this discussion group have previously helped me to dynamically
identify CD rom drives etc at runtime using objects in System.management

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

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
Next
++++++++++++++++++++++++++++++++++++++++++++++++++ +++

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

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 system.management 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

Ben
Jul 21 '05 #1
0 1509

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ben Reese | last post by:
Kind people on this discussion group have previously helped me to dynamically identify CD rom drives etc at runtime using objects in System.management +++++++++++++++++++++++++++++++++++++++ Dim...
0
by: BK Drake | last post by:
I am trying to assign a drive letter to a hidden partition. I have a hard drive that has 2 paritions - a system and a data partition. When I retore with an image the system drive the data drive...
0
by: john doe | last post by:
How can I use WMI or a WqlObjectQuery to find the hard drive letter of the physical drive location index. For example the following code will give me the physical drive location:...
7
by: jimdscudder | last post by:
How can I use WMI or a WqlObjectQuery to find the hard drive letter of the physical drive location index. For example the following code will give me the physical drive location:...
4
by: sanjana | last post by:
hi i m using the win32_diskdrive class for detecting a memory card insertion and removal..and this class detects memory card(sd card..etc) insertion removal from the device the deviceid...
0
by: Ben Reese | last post by:
Kind people on this discussion group have previously helped me to dynamically identify CD rom drives etc at runtime using objects in System.management +++++++++++++++++++++++++++++++++++++++ Dim...
2
by: Kavitha | last post by:
Hi , Can any one tel me how to create a virtual drive in C#( similar to Gmail Virtual drive).Also tell me what interfaces could be used to create the same. Thanks in Advance Kavitha
4
by: Luc The Perverse | last post by:
Hi - I have very little C# programming experience. I am making a software product which calls for an interface almost identical to Windows Explorer - and I wondered if mounting a "virtual drive"...
3
by: Killer42 | last post by:
Hi all. Summary Plugging flash drive into work PC, no drive appears. Details First of all, I have searched TheScripts for an answer. The closest I found was this article which covered...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.