开发者

How can I query a particular instance of a WMI class?

I am able to query all of the instances using:

Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_PerfFormattedData_ASPNET_ASPNETApplications", "WQL", _
                                         wbemFlagReturnImmediately + wbemFlagForwardOnly  )
  For Each objItem In colItems
     WScript.Echo "Requests Total: " & objItem.Requests开发者_C百科Total
  Next

How do I query a particular instance in this class; for instance _LM_W3SVC1_ROOT_MyApp?


You can use SWbemServices.Get() specifying the full or relative path to the instance:

Set objWMIService = GetObject("winmgmts:")
Set objItem = objWMIService.Get _
    ("Win32_PerfFormattedData_ASPNET_ASPNETApplications.Name='__Total__'")

WScript.Echo objItem.Name

This means you need to know the values all the key properties for the instance. Win32_PerfFormattedData_ASPNET_ASPNETApplications key property is Name. I used Total because I don't have any ASP .Net applications on my computer. Note that there are no spaces in the instance path string.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜