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

Help with WMI Logical Disks Space.

Hi.
Hopefully somebody out there will be able to help me!

I am using VB.Net and I am trying to find out logical disk
information.

I would like to be able to find the drive letters of any logical
disks, the size of each partition and how much free space is available
on the partition.

I have used the following code to list automatic services using WMI

Public Function GetAutoServices(ByVal Server As String) As
Collection
Dim colServices
Dim objService As Object
Dim colTemp As New Collection

Try
colServices = GetObject("winmgmts:
{impersonationLevel=impersonate}!\\" _
& Server & "\root\cimv2").ExecQuery("Select * from
Win32_Service")

For Each objService In colServices
If objService.StartMode = "Auto" Then
colTemp.Add(New Service(objService.DisplayName,
objService.State))
End If
Next

Return colTemp
Catch ex As Exception
MessageBox.Show(ex.Message)
Return colTemp
End Try
End Function

is it possible to find out the info i want using this method?

May 16 '07 #1
1 3491
TeeJayEm,

Start a new console app

Add references to:

System.Management
System.Windows.Forms

Imports:

Imports System.Management
Imports System.Windows.Forms

Module Module1

Sub Main()
Try
Dim searcher As New
ManagementObjectSearcher("root\CIMV2","SELECT * FROM Win32_LogicalDisk")

For Each queryObj As ManagementObject In searcher.Get()

Console.WriteLine("-----------------------------------------")
Console.WriteLine("DeviceID: {0}", queryObj("DeviceID"))
Console.WriteLine("VolumeName: {0}", queryObj("VolumeName"))
Console.WriteLine("VolumeSerialNumber: {0}",
queryObj("VolumeSerialNumber"))
Console.WriteLine("FileSystem: {0}", queryObj("FileSystem"))
Console.WriteLine("DriveType: {0}", queryObj("DriveType"))
Console.WriteLine("Size: {0}", queryObj("Size"))
Console.WriteLine("FreeSpace: {0}", queryObj("FreeSpace"))
Next
Console.ReadLine()
Catch mex As ManagementException
MessageBox.Show("An error occurred: " & mex.Message)
End Try
End Sub

End Module

I hope this helps,

--
Newbie Coder
(It's just a name)
<te******@gmail.comwrote in message
news:11**********************@u30g2000hsc.googlegr oups.com...
Hi.
Hopefully somebody out there will be able to help me!

I am using VB.Net and I am trying to find out logical disk
information.

I would like to be able to find the drive letters of any logical
disks, the size of each partition and how much free space is available
on the partition.

I have used the following code to list automatic services using WMI

Public Function GetAutoServices(ByVal Server As String) As
Collection
Dim colServices
Dim objService As Object
Dim colTemp As New Collection

Try
colServices = GetObject("winmgmts:
{impersonationLevel=impersonate}!\\" _
& Server & "\root\cimv2").ExecQuery("Select * from
Win32_Service")

For Each objService In colServices
If objService.StartMode = "Auto" Then
colTemp.Add(New Service(objService.DisplayName,
objService.State))
End If
Next

Return colTemp
Catch ex As Exception
MessageBox.Show(ex.Message)
Return colTemp
End Try
End Function

is it possible to find out the info i want using this method?

May 16 '07 #2

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

Similar topics

0
by: pptran | last post by:
Hi, I am pretty new to building and installing Perl. Can someone help explain the severity of the following Perl 5.8.4 build error message? ==================================================...
6
by: Hari Om | last post by:
Here are the details of my error log files: I execute the command and get following message at console: ---------------------------------------------------------------------- ../sqlldr...
1
by: Mike Hibbert | last post by:
Hello All, I am looking at the performance of our production database. It is 40gb, and growing reasonably fast. It is placed in one file group on a RAID-5 array. The array is made up of 20 (or...
4
by: Morgan Leppink | last post by:
Hey all - We are running SQL 2000 with ALL available service packs, etc. applied. We just built a brand new database server, which has dual 2Ghz XEONs, 2GB memory, and the following disk...
0
by: Alstersjo | last post by:
Hi Does anybody know how to recieve a list of disks on an remote server. I also want to recieve information about total space and free space.
5
by: coinjo | last post by:
A structure of type MetallicDisk stores the measurements of a disk. The measurements are Outer - specifies outer radius of the disk. Inner - specifies the inner radius of the disk. Inner radius is...
2
by: jhhbr549 | last post by:
I need my result to print out only in the box created with a scroll bar. It has to look like this. The Twelve Days of It by John H. Howard On the First day of It My true LOVE of Computers...
2
by: Jim Flanagan | last post by:
Hi... I am using VB.net Express to experiment with the Win32 API functions that are available. The current project is an application that will read the raw sectors of a logical drive so that a...
7
by: raylopez99 | last post by:
I have a logical drawing space much bigger than the viewport (the screen) and I'd like to center the viewport (the screen) to be at the center of the logical drawing space. After following the...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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
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,...

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.