使用 vbscript 从 WMI 类获取描述 [英] get the description from an WMI class using vbscript

查看:34
本文介绍了使用 vbscript 从 WMI 类获取描述的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 vbscript 从 WMI 类中获取描述?

How can I get the description from an WMI class using vbscript?

我找到了这个例子,但它是用 C# 编写的:

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.

推荐答案

以下是与 C# 代码等效的 VBScript(仅没有错误处理):

Here's the VBScript equivalent of your C# code (only without error handling):

Const wbemFlagUseAmendedQualifiers = &H20000

strComputer = "."
Set oWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set oClass = oWMI.Get("Win32_LogicalDisk", wbemFlagUseAmendedQualifiers)

strDesc = oClass.Qualifiers_("Description").Value
WScript.Echo strDesc

这篇关于使用 vbscript 从 WMI 类获取描述的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆