
On Fri, Jan 29, 2010 at 12:00 PM, Rad! <conradakunga@gmail.com> wrote:
Let's do some basic troubleshooting
1. Remove the filter criteria and see if it runs. If it does then the problem is the filter 2. 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.