我如何获取 WMI 类方法的参数类型
我如何使用 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
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您得到的 objInParam 是 SWbemPropertySet 包含 SWbemProperty 正如您在文档中看到的,该类没有
Type
属性。但是,有 CIMType 属性您可以使用它来代替。唯一的困难是
CIMType
返回一个Integer
,但您可以在 WbemCimTypeEnum 枚举。因此,如果您对整数感到满意,则必须将代码更改为:
或者,如果您需要字符串名称,则必须执行以下操作:
The
objInParam
you get out is a SWbemPropertySet that contains SWbemProperty and as you can see in the docs, there is noType
property of that class. However, there is the CIMType property that you can use instead.The only difficulty with this is that
CIMType
returns anInteger
, 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:
Or if you need a string name you'd have to do something like: