Home All Groups Group Topic Archive Search About

'System.Management.ManagementClass' is not defined

Author
26 Nov 2006 8:59 AM
Anil Gupte
I am getting this error: Type 'System.Management.ManagementClass' is not
defined. The statement is:
Dim diskClass As New System.Management.ManagementClass("Win32_LogicalDisk")


According to the help file, this 'System.Management.ManagementClass' is
under System.Object, so I put in the

Imports System.Object
in namespace, but that seems not to help.

Any suggestions?
Thanx in advance,

Author
26 Nov 2006 9:59 AM
Oenone
Anil Gupte wrote:
> I am getting this error: Type 'System.Management.ManagementClass' is
> not defined. The statement is:
> Dim diskClass As New
> System.Management.ManagementClass("Win32_LogicalDisk")

You need to add a reference to System.Management.dll, then it'll work.

HTH,

--

(O)enone
Author
26 Nov 2006 11:33 AM
Anil Gupte
Thanx!  That worked!

Show quoteHide quote
"Oenone" <oen***@nowhere.com> wrote in message
news:9Adah.21138$Fv1.19222@newsfe2-win.ntli.net...
> Anil Gupte wrote:
>> I am getting this error: Type 'System.Management.ManagementClass' is
>> not defined. The statement is:
>> Dim diskClass As New
>> System.Management.ManagementClass("Win32_LogicalDisk")
>
> You need to add a reference to System.Management.dll, then it'll work.
>
> HTH,
>
> --
>
> (O)enone
>
Author
26 Nov 2006 11:53 AM
Anil Gupte
As I said it helpd, but raises another question.

What other options are there other than Win32_LogicalDisk?  I want only
local Read/Write Disks (I wan tot create a temporary file and I am trying to
find the first disk that has enough space and I can write to).

I did a searh in the help, but came up with nothing.  There is some code:
Dim diskClass As New System.Management.ManagementClass("Win32_LogicalDisk")

Dim disks As System.Management.ManagementObjectCollection =
diskClass.GetInstances()

Dim disk As System.Management.ManagementObject

Dim space As System.UInt64

For Each disk In disks

If CStr(disk("Name")) = "C:" Then

space = CType(disk("FreeSpace"), System.UInt64)

End If

Next disk

But this does not help because it is Logical disk.  I know there is an
IsLocal property, but I wish there was a more direct way and also, will
IsLocal give me the CD-ROM drive, which obviously I cannot write to.

Thanx in advance,
Show quoteHide quote
"Oenone" <oen***@nowhere.com> wrote in message
news:9Adah.21138$Fv1.19222@newsfe2-win.ntli.net...
> Anil Gupte wrote:
>> I am getting this error: Type 'System.Management.ManagementClass' is
>> not defined. The statement is:
>> Dim diskClass As New
>> System.Management.ManagementClass("Win32_LogicalDisk")
>
> You need to add a reference to System.Management.dll, then it'll work.
>
> HTH,
>
> --
>
> (O)enone
>