1
Vote

Non-default namespace classes

description

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;
            break;
        }
        management.Dispose();
        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

comments