How i can get the types of the parameters of an method for a WMI class
How i can get the parameters types of an method for a WMI class using vbscript
actually i'm using this script
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
The objInParam
you get out is a SWbemPropertySet that contains SWbemProperty and as you can see in the docs, there is no Type
property of that class. However, there is the CIMType property that you can use instead.
The only difficulty with this is that CIMType
returns an Integer
, but you can find all the possible values in the documentation for the WbemCimTypeEnum enum.
So if you'd be happy with the integer you'd have to change your code to:
For Each Property In objInParam
WScript.Echo Property.Name
WScript.Echo Property.CIMType
Next
Or if you need a string name you'd have to do something like:
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
精彩评论