Windows 使用vbscript从WMI类获取描述
如何使用vbscript从WMI类获取描述 我找到了这个例子,但它是C#: 这张图显示了我所需要的Windows 使用vbscript从WMI类获取描述,windows,vbscript,wmi,Windows,Vbscript,Wmi,如何使用vbscript从WMI类获取描述 我找到了这个例子,但它是C#: 这张图显示了我所需要的 以下是与C#代码等效的VBScript(仅在没有错误处理的情况下): 给出一个这个类的例子和你期望看到的。 // Gets the class description. try { // Gets the property qualifiers. ObjectGetOptions op = new ObjectGetOptions(null, System.TimeSpan.Max
以下是与C#代码等效的VBScript(仅在没有错误处理的情况下):
给出一个这个类的例子和你期望看到的。
// 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());
}
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