【问题标题】:get the description from an WMI class using vbscript使用 vbscript 从 WMI 类中获取描述
【发布时间】:2010-10-20 14:28:31
【问题描述】:

如何使用 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());
}

这张图片显示了我需要的东西。

【问题讨论】:

  • 举一个这个类的例子和你期望看到的。

标签: windows vbscript wmi


【解决方案1】:

这是您的 C# 代码的 VBScript 等效项(仅没有错误处理):

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-02
    • 2015-01-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多