Export (0) Print
Expand All

Returning Selected Properties of Selected Instances of a Class

Microsoft® Windows® 2000 Scripting Guide

You also have the option of returning only selected properties of selected classes. To do this, you must:

  • Specify the properties to be returned.

  • Include a WHERE clause to limit the instances returned.

In other words, this type of query combines two query types returning selected properties and returning selected instances explored earlier in this chapter.

For example, this script returns only the name and the state of services that can be paused:



strComputer = "."
Set objSWbemServices = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colServices = objSWbemServices.ExecQuery _
    ("SELECT Name, State FROM Win32_Service WHERE AcceptPause = True")

For Each objService In colServices
    Wscript.Echo objService.Name, objService.State
Next

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft