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.
精彩评论