使用 vbscript 从 WMI 类获取描述
如何使用 vbscript 从 WMI 类获取描述?
我找到了这个例子,但它是用 C# 编写的:
// Gets the class description.
try
{
// Gets the property qualifiers.
ObjectGetOptions op = new ObjectGetOptions(null, System.TimeSpan.MaxValue, true);
ManagementClass mc = new ManagementClass(namespace,
classname, op);
mc.Options.UseAmendedQualifiers = true;
foreach (QualifierData dataObject in
mc.Qualifiers)
{
if(dataObject.Name.Equals("Description"))
{
classdesc =
dataObject.Value.ToString();
}
}
}
catch (ManagementException mErr)
{
if(mErr.Message.Equals("Not found "))
MessageBox.Show("WMI class or not found.");
else
MessageBox.Show(mErr.Message.ToString());
}
这张图片显示了我需要的内容。
How can I get the description from an WMI class using vbscript?
I found this example but it's in C#:
// Gets the class description.
try
{
// Gets the property qualifiers.
ObjectGetOptions op = new ObjectGetOptions(null, System.TimeSpan.MaxValue, true);
ManagementClass mc = new ManagementClass(namespace,
classname, op);
mc.Options.UseAmendedQualifiers = true;
foreach (QualifierData dataObject in
mc.Qualifiers)
{
if(dataObject.Name.Equals("Description"))
{
classdesc =
dataObject.Value.ToString();
}
}
}
catch (ManagementException mErr)
{
if(mErr.Message.Equals("Not found "))
MessageBox.Show("WMI class or not found.");
else
MessageBox.Show(mErr.Message.ToString());
}
This image shows what I need.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
下面是与 C# 代码等效的 VBScript(仅没有错误处理):
Here's the VBScript equivalent of your C# code (only without error handling):