473,320 Members | 1,820 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 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 1669

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: 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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.