WMI

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I would like to convert a VBS to C# that retrieves all devices info on a
system from "Win32_CIMLogicalDeviceCIMDataFile" class.

....
Set wmiColls = objWMI.ExecQuery("SELECT * FROM
Win32_CIMLogicalDeviceCIMDataFile")

For Each wmiColl In wmiColls
[1] Set ao = GetObject("winmgmts:" & wmiColl.antecedent)
[2] Set do = GetObject("winmgmts:" & wmiColl.dependent)
....

I don't know how to convert [1] and [2] to C#.

Can anyone please help?

Thanks in advance,
-P
 
| Hi,
|
| I would like to convert a VBS to C# that retrieves all devices info on a
| system from "Win32_CIMLogicalDeviceCIMDataFile" class.
|
| ...
| Set wmiColls = objWMI.ExecQuery("SELECT * FROM
| Win32_CIMLogicalDeviceCIMDataFile")
|
| For Each wmiColl In wmiColls
| [1] Set ao = GetObject("winmgmts:" & wmiColl.antecedent)
| [2] Set do = GetObject("winmgmts:" & wmiColl.dependent)
| ...
|
| I don't know how to convert [1] and [2] to C#.
|
| Can anyone please help?
|
| Thanks in advance,
| -P


It would save you some time if you did consult the docs before posting, but
here it goes...

ManagementClass c = new
ManagementClass("Win32_CIMLogicalDeviceCIMDataFile");
ManagementObjectCollection moc = c.GetInstances();
ManagementObject[] dependents = new ManagementObject[c.Count];
int i = 0;
foreach (ManagementObject o in moc)
dependents[i++] = new ManagementObject(o["dependent"].ToString());
// create dependent object

Note that you might get better answers when posting to the
microsoft.public.dotnet.framework.wmi NG.

Willy.
 
I can't find the newsgroup you were referring to on the left navigation panel.

Thanks anyway,
-P
 
Not sure what news reader you are using, but you need to add the NG to the
navigation pane first.

Willy.


|I can't find the newsgroup you were referring to on the left navigation
panel.
|
| Thanks anyway,
| -P
|
| "Willy Denoyette [MVP]" wrote:
|
| >
| > | > | Hi,
| > |
| > | I would like to convert a VBS to C# that retrieves all devices info on
a
| > | system from "Win32_CIMLogicalDeviceCIMDataFile" class.
| > |
| > | ...
| > | Set wmiColls = objWMI.ExecQuery("SELECT * FROM
| > | Win32_CIMLogicalDeviceCIMDataFile")
| > |
| > | For Each wmiColl In wmiColls
| > | [1] Set ao = GetObject("winmgmts:" & wmiColl.antecedent)
| > | [2] Set do = GetObject("winmgmts:" & wmiColl.dependent)
| > | ...
| > |
| > | I don't know how to convert [1] and [2] to C#.
| > |
| > | Can anyone please help?
| > |
| > | Thanks in advance,
| > | -P
| >
| >
| > It would save you some time if you did consult the docs before posting,
but
| > here it goes...
| >
| > ManagementClass c = new
| > ManagementClass("Win32_CIMLogicalDeviceCIMDataFile");
| > ManagementObjectCollection moc = c.GetInstances();
| > ManagementObject[] dependents = new ManagementObject[c.Count];
| > int i = 0;
| > foreach (ManagementObject o in moc)
| > dependents[i++] = new
ManagementObject(o["dependent"].ToString());
| > // create dependent object
| >
| > Note that you might get better answers when posting to the
| > microsoft.public.dotnet.framework.wmi NG.
| >
| > Willy.
| >
| >
| >
| >
| >
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top