views:

18

answers:

1

Hi, i need to know how can get the descrption from an WMI class using vbscript.

i just founs this example but is 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 represent wich is i need.

alt text

thanks in advance.

+4  A: 

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
Helen
+1 @Helen. You beat me to it.
Garett
Thanks very much Helen.
Salvador