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.
Retrieve a local copy of the instance with a call to the VBScript GetObject method.
To retrieve an instance of a WMI class using VBScript
- Call GetObject with the object path of the instance as shown in the following example.
Retrieving a specific instance requires giving a name as part of the object path.
In C++, call IWbemServices::GetObject.
To retrieve an instance of a WMI class using C++
- Retrieve a local copy of the instance with a call to
IWbemServices::GetObjectAsync. The WMI path to the object must be included.
As the name implies, GetObjectAsync retrieves the instance asynchronously, while GetObject retrieves the instance synchronously. If you want to use asynchronous retrieval, you must implement the IWbemObjectSink interface.
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.