如何使用vbscript
获取WMI类的方法的参数类型实际上我正在使用这个脚本
strComputer = "."
strNameSpace = "root\cimv2"
Set objServices = GetObject("winmgmts:root\cimv2")
Set objShare = objServices.Get("Win32_Share")
Set objInParam = objShare.Methods_("Create"). _
inParameters.Properties_
For Each Property In objInParam
WScript.Echo Property.Name
WScript.Echo Property.Type //here this code fails, how i can get the type name ?
Next
答案 0 :(得分:2)
您获得的objInParam
是SWbemPropertySet,其中包含SWbemProperty,正如您在文档中看到的那样,该类没有Type
属性。但是,您可以使用CIMType属性。
唯一的问题是CIMType
会返回Integer
,但您可以在WbemCimTypeEnum枚举的文档中找到所有可能的值。
因此,如果您对整数感到满意,则必须将代码更改为:
For Each Property In objInParam
WScript.Echo Property.Name
WScript.Echo Property.CIMType
Next
或者,如果您需要字符串名称,则必须执行以下操作:
For Each Property In objInParam
WScript.Echo Property.Name
WScript.Echo GetTypeName(Property.CIMType)
Next
Function GetTypeName(typeNumber)
' fill in with a lookup table to the WbemCimTypeEnum '
End Function