Export (0) Print
Expand All

Retrieving an Instance

Retrieving an instance is one of the most common retrieval procedures you are likely to perform in WMI. You can retrieve an existing instance or create a new unnamed instance. The WMI path to the existing instance is a required parameter. For more information, see Describing the Location of a WMI Object.

Note  When providing an instance, a provider may be unable to provide a value for certain properties. Unless otherwise stated in the property description, you cannot infer any meaning from an empty value. This is not to be confused with a string which has a NULL value. In this case, the value is populated. It is empty but has a value: NULL.

Retrieve a local copy of the instance with a call to the VBScript GetObject method.

Aa393243.wedge(en-us,VS.85).gifTo retrieve an instance of a WMI class using VBScript

  • Call GetObject with the object path of the instance as shown in the following example.
    
    Set objinst = GetObject("WinMgmts:Win32_LogicalDisk='C:'")
    
    

    Retrieving a specific instance requires giving a name as part of the object path.

In C++, call IWbemServices::GetObject.

Aa393243.wedge(en-us,VS.85).gifTo retrieve an instance of a WMI class using C++

Examples

For a VBScript example to use as a template to retrieve class and instance information, see the WMI Template Script example on TechNet Gallery. This particular example uses GetObject to retrieve the WMI Service.

 

 

Show:
© 2014 Microsoft