Non-default namespace classes

Oct 18, 2010 at 2:42 PM
Edited Oct 18, 2010 at 2:47 PM

Hi, first - thanks for this nice project.

I have a need to access non standard (aka not root\cimv2) wmi namespaces. I modified a copy of the code to be able to handle this. For reference the only changes I had to make are:

Arguments.cs (adding)


private string _wmiNs = "root\\cimv2";

[Argument("wmins", HelpText = "WMI namespace for class for!")]
        public string WmiNs
            get { return _wmiNs; }
            set { _wmiNs = value; }


WmiObjectQuery.cs (changes)

public ManagementObject GetMetaInformation(string name, string nameSpace)
            ManagementObject value = null;
            ManagementScope scope = new ManagementScope(@"\\localhost\" + nameSpace);

            ManagementPath path = new ManagementPath(name);
            ManagementClass management = new ManagementClass(scope, path, null);
            foreach (ManagementObject child in management.GetInstances())
                value = child;
            return value;

[Update:] forgot to add an example. Querying the WMI objects for BizTalk would look like this:
  LinqToWmi.ClassGenerator.exe /wmi:MSBTS_HostInstance /wmins:root\MicrosoftBizTalkServer
Jan 8, 2011 at 12:24 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.