473,402 Members | 2,055 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,402 software developers and data experts.

How to change a drive letter with system.management

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 1679

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...
2
by: Jason Chan | last post by:
how can i know how many drive in computer? Thanks in advance
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: 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...
8
by: Chad | last post by:
To anyone who is smarter than I am when it comes to WMI: Here is what I am trying to do: 1) Detect a USB pen drive when it is inserted 2) Retrieve the drive letter of the pen drive 3) Check...
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
13
by: =?Utf-8?B?RGF2ZQ==?= | last post by:
I am actually trying to get the UNC path of the main module of a process running from a mapped drive, and I am trying to do this from a service. The ProcessModule class only provides the full path...
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"...
1
by: Talal Itani | last post by:
I am writing code that accesses an MP3 player plugged to a USB port. The MP3 player is not showing up as a drive letter. With explorer, I see the drive, with it's name, but no drive letter is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.