Редактиране

Споделяне чрез


Creating an Object Using VBScript

You can create an object for WMI in Visual Basic Scripting Edition (VBScript) by connecting to WMI and then calling CreateObject. The following table lists the methods in the Scripting API for WMI that support object creation.

Interface ProgID
SWbemDateTime "WbemScripting.SwbemDateTime"
SWbemLocator "WbemScripting.SWbemLocator"
SWbemLastError "WbemScripting.SWbem.LastError"
SWbemObjectPath "WbemScripting.SWbemObjectPath"
SWbemNamedValueSet "WbemScripting.SWbemNamedValueSet"
SWbemRefresher "WbemScripting.SWbemRefresher"
SWbemSink "WbemScripting.SWbemSink"

 

The following procedure describes how to create a WMI object using VBScript.

To create a WMI object using VBScript

  1. Connect to WMI using either a moniker or an SWbemLocator object.

    For more information, see Creating a WMI Script.

  2. Make a call to the VBScript CreateObject method.

    The following code example shows how to create an object.

    Set locator = CreateObject("WbemScripting.SWbemLocator")
    

    If you use a moniker in Step 1, you do not need to call CreateObject again.