473,386 Members | 1,810 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,386 software developers and data experts.

IWSHRuntimeLibrary

I am trying to use the DriveClass to get the information for a drive but
can't seem to get the syntax, etc. correct.

I tried:

dim drives as DrivesClass = ??????????? tried NEW but it's private
dim d as drive
for each d in drives

next

--
Dennis in Houston
Nov 21 '05 #1
2 3847
Hi,

To get a list of drives you can use the wmi or the environment class.
The environment class only returns the drive letters use the wmi to get info
about the drive.

Environment class

For Each strDrive As String In Environment.GetLogicalDrives

Trace.WriteLine(strDrive)

Next

WMI

Add a reference to system.management to your app

' Add a Reference to System.Management

Dim moReturn As Management.ManagementObjectCollection

Dim moSearch As Management.ManagementObjectSearcher

Dim mo As Management.ManagementObject

moSearch = New Management.ManagementObjectSearcher("Select * from
Win32_LogicalDisk")

moReturn = moSearch.Get

For Each mo In moReturn

Dim strOut As String

strOut = String.Format("Drive {0} - Drive Type {1}", mo("Name"),
mo("DriveType"))

Trace.WriteLine(strOut)

Next

http://msdn.microsoft.com/library/de...ogicaldisk.asp

Ken

----------------------------------

"Dennis" <De****@discussions.microsoft.com> wrote in message
news:11**********************************@microsof t.com...
I am trying to use the DriveClass to get the information for a drive but
can't seem to get the syntax, etc. correct.

I tried:

dim drives as DrivesClass = ??????????? tried NEW but it's private
dim d as drive
for each d in drives

next

--
Dennis in Houston
Nov 21 '05 #2
Yes, I know there are several ways to get the drives but I was playing around
with Iwshruntimelibrary. With it, you can enumerate the shared drives and
folders. The Win32Logical Class only enumerates the drives and mapped
network drives, not the shared network places.

"Ken Tucker [MVP]" wrote:
Hi,

To get a list of drives you can use the wmi or the environment class.
The environment class only returns the drive letters use the wmi to get info
about the drive.

Environment class

For Each strDrive As String In Environment.GetLogicalDrives

Trace.WriteLine(strDrive)

Next

WMI

Add a reference to system.management to your app

' Add a Reference to System.Management

Dim moReturn As Management.ManagementObjectCollection

Dim moSearch As Management.ManagementObjectSearcher

Dim mo As Management.ManagementObject

moSearch = New Management.ManagementObjectSearcher("Select * from
Win32_LogicalDisk")

moReturn = moSearch.Get

For Each mo In moReturn

Dim strOut As String

strOut = String.Format("Drive {0} - Drive Type {1}", mo("Name"),
mo("DriveType"))

Trace.WriteLine(strOut)

Next

http://msdn.microsoft.com/library/de...ogicaldisk.asp

Ken

----------------------------------

"Dennis" <De****@discussions.microsoft.com> wrote in message
news:11**********************************@microsof t.com...
I am trying to use the DriveClass to get the information for a drive but
can't seem to get the syntax, etc. correct.

I tried:

dim drives as DrivesClass = ??????????? tried NEW but it's private
dim d as drive
for each d in drives

next

--
Dennis in Houston

Nov 21 '05 #3

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

Similar topics

0
by: Craig Matthews | last post by:
I have the following code snippit written in VB.NET to map a network drive to the local machine. This works perfectly and throws the proper exceptions when the parameters are wrong or unreachable...
2
by: John O'Neill | last post by:
Hi I have a c# application that I sign with a strong name key which is fine, but when I add a reference to IWshRuntimeLibrary I get the following error when I build my project:- error CS1577:...
2
by: Dale Magnuson | last post by:
I originally had all of my C# work on my local PC. Because this is dangerous I moved it off to a network drive. Since I did this I can no longer compile my code - I get the error below. The...
1
by: G$ | last post by:
I'm trying to write some C# code to call the Windows Scripting Host (WSH) to create shortcuts, but I'm having problems. First, I referenced Windows Script Host Object Model. Then, I wrote the...
2
by: Mike | last post by:
I'm trying to generate a shortcut file from VB. The code below is a cutdown version of some code I found on the net that is supposed to do the job The compiler complains about "WshShell" in the...
0
by: kennji | last post by:
I got the following codes written in vwd 2005 and it works after i ran it.i was able to open a notepad.exe after clicking the button but after i put the folder into inetpub\wwwroot and try to view...
46
by: OldBirdman | last post by:
What a mess this question is. I have spent 2 weeks trying to make it concise and clear, and I can't. I do not have the vocabulary for the question. I cannot even TITLE it correctly. Here is my...
3
FishVal
by: FishVal | last post by:
Windows Script Host Object library. Full name: Windows Script Host Object Model LibName: IWshRuntimeScripting Location: ...\WINDOWS\system32\wshom.ocx The present tip is closely related to...
6
by: Joe Duchtel | last post by:
Hello - I'm trying to put together a little VB .NET (1.1 in VS 2003) application that lets me substitute the path in the Target: and Start in: fields of *.lnk files. Is there any way to do...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.