I had also removed the filter and it still behaved the same. I am 100000000% sure that the code is perfect, just like the C# snippet has vindicated. Anyway, I run the C# application and got the message below:
On Fri, Jan 29, 2010 at 12:00 PM, Rad! <conradakunga@gmail.com> wrote:
Let's do some basic troubleshooting
- Remove the filter criteria and see if it runs. If it does then the problem is the filter
- Put back the filter but before you loop through the collection, check the number of items in the collection. there should be a Count or Length property that you can check
@Simon, while Rad has suggested the above, pls also run the general C Sharp script below. The script below runs well on my machine. HTHs to root cause, especially with the messagebox display error.using System;
using System.Management;
using System.Windows.Forms;namespace WMISample
{
public class MyWMIQuery
{
public static void Main()
{
try
{
ManagementObjectSearcher searcher =
new ManagementObjectSearcher("root\\CIMV2",
"SELECT * FROM Win32_ClassicCOMClassSetting");foreach (ManagementObject queryObj in searcher.Get())
{
Console.WriteLine("-----------------------------------");
Console.WriteLine("Win32_ClassicCOMClassSetting instance");
Console.WriteLine("-----------------------------------");
Console.WriteLine("Caption: {0}", queryObj["Caption"]);
}
}
catch (ManagementException e)
{
MessageBox.Show("An error occurred while querying for WMI data: " + e.Message);
}
}
}
}Rgds.
_______________________________________________
Skunkworks mailing list
Skunkworks@lists.my.co.ke
http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks
------------
Skunkworks Server donations spreadsheet
http://spreadsheets.google.com/ccc?key=0AopdHkqSqKL-dHlQVTMxU1VBdU1BSWJxdy1fbjAwOUE&hl=en
------------
Skunkworks Rules
http://my.co.ke/phpbb/viewtopic.php?f=24&t=94
------------
Other services @ http://my.co.ke
Other lists
-------------
Announce: http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks-announce
Science: http://lists.my.co.ke/cgi-bin/mailman/listinfo/science
kazi: http://lists.my.co.ke/cgi-bin/mailman/admin/kazi/general