How to call a WMI method
The main purpose of WMI is to provide access to classes and instances that represent objects on your network. These classes and instances are supported by providers. For example, all of the instances that represent standard hardware devices on your enterprise, such as Win32_PhysicalMemory or Win32_Printer, are supported by the Win32 provider. Similarly, you can access the event log through the Event Log provider, and the registry through the Registry provider.
The methods that WMI implements in interfaces such as IWbemServices or scripting objects such as SWbemServices, are primarily for generically obtaining and manipulating data supplied by any provider. For example, use SWbemServices.InstancesOf to obtain all the instances of Win32_Process in a subset of enterprise computers. You can then call the Win32 provider method GetOwnerSid on each Win32_Process object.
In the following example, the GetOwnerSid method is called as an automation method on the Process object. A WMI method, such as the Path_ method defined for SWbemObject could also be called on the Process object.
Set ProcessCollection = _ GetObject("WinMgmts:").InstancesOf("Win32_Process") For Each Process In ProcessCollection SID = Process.GetOwnerSid Next
The actual process of using the WMI methods is identical to using any other Windows COM or automation interface. For more information, see COM and Creating a WMI Application or Script. For more information about the interfaces that WMI supports, see COM API for WMI and Scripting API for WMI.
For more information, see Manipulating Class and Instance Information.