SWbemPropertySet 对象

SWbemPropertySet 对象是 SWbemProperty 对象的集合。 可以使用 Add 方法将项添加到集合、使用 Item 方法从集合中检索项,并使用 Remove 方法从集合中删除项。 有关详细信息,请参阅访问集合。 此对象不能由 VBScript CreateObject 调用创建。

构成 SWbemPropertySet 集合的 SWbemProperty 对象用于描述单个 WMI 类或实例的属性。

成员

SWbemPropertySet 对象具有以下类型的成员:

方法

SWbemPropertySet 对象具有以下方法。

方法 说明
Add 将 SWbemProperty 对象添加到 SWbemPropertySet 集合。
项 从集合中获取命名的 SWbemProperty。 这是此对象的默认方法。
Remove 从集合中删除 SWbemProperty 对象。

属性

SWbemPropertySet 对象具有以下属性。

属性 访问类型 说明
计数
只读
SWbemPropertySet 集合中项的数量。

示例

下面的 VBScript 示例演示如果替代了属性,SWbemPropertySet.Remove 如何能返回 wbemErrResetToDefault。

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

要求

要求 值
最低受支持的客户端
Windows Vista
最低受支持的服务器
Windows Server 2008
标头
Wbemdisp.h
类型库
Wbemdisp.tlb
DLL
Wbemdisp.dll
CLSID
CLSID_SWbemPropertySet
IID
IID_ISWbemPropertySet

另请参阅

脚本 API 对象