Muokkaa

Jaa


SWbemPropertySet object

An SWbemPropertySet object is a collection of SWbemProperty objects. You can add items to the collection using the Add method, retrieve items from the collection using the Item method, and remove items from the collection using the Remove method. For more information, see Accessing a Collection. This object cannot be created by the VBScript CreateObject call.

The SWbemProperty objects that make up an SWbemPropertySet collection are used to describe the properties of a single WMI class or instance.

Members

The SWbemPropertySet object has these types of members:

Methods

The SWbemPropertySet object has these methods.

Method Description
Add Adds an SWbemProperty object to the SWbemPropertySet collection.
Item Gets a named SWbemProperty from the collection. This is the default method for this object.
Remove Deletes an SWbemProperty object from the collection.

Properties

The SWbemPropertySet object has these properties.

Property Access type Description
Count
Read-only
The number of items in the SWbemPropertySet collection.

Examples

The following VBScript sample demonstrates how SWbemPropertySet.Remove can return wbemErrResetToDefault if the property is overridden.

on error resume next 

'Create a keyed class with a defaulted property
set service = GetObject("Winmgmts:")
set emptyclass = service.Get
emptyclass.path_.class = "REMOVETEST00"
set prop = emptyclass.properties_.add ("p", 19)

prop.qualifiers_.add "key", true
emptyclass.properties_.add ("q", 19).Value = 12

emptyclass.put_

'create an instance and override the property
set instance = service.get ("RemoveTest00").spawninstance_

instance.properties_("q").Value = 24
instance.properties_("p").Value = 1
instance.put_

'retrieve the instance and remove the property
set instance = service.get ("removetest00=1")
set property = instance.properties_ ("q")

WScript.echo "Overridden value of property is [24]:", property.value
WScript.echo ""

instance.properties_.remove "q"
set property = instance.properties_ ("q")
WScript.echo "Value of property after removal is [12]:", property.value
WScript.echo ""

if err <> 0 then
 WScript.Echo "0x" & Hex(Err.Number), Err.Description, Err.Source
end if

Requirements

Requirement Value
Minimum supported client
Windows Vista
Minimum supported server
Windows Server 2008
Header
Wbemdisp.h
Type library
Wbemdisp.tlb
DLL
Wbemdisp.dll
CLSID
CLSID_SWbemPropertySet
IID
IID_ISWbemPropertySet

See also

Scripting API Objects