The code segment in Example 4–17 gets the instances of the CIM_Service class (services that manage device or software features) and uses the invokeMethod method to stop each service.
{
...
/* Pass the CIM Object Path of the CIM_Service class
to the CIM Object Manager. We want to invoke a method defined in
this class. */
CIMObjectPath op = new CIMObjectPath("CIM_Service");
/* The CIM Object Manager returns an enumeration of instance
object paths, the names of instances of the CIM_Service
class. */
Enumeration e = cc.enumInstances(op, cc.DEEP);
/* Iterate through the enumeration of instance object paths.
Use the CIM Client getInstance class to get
the instances referred to by each object path. */
while(e.hasMoreElements()) {
// Get the instance
CIMInstance ci = cc.getInstance(e.nextElement(), true);
//Invoke the Stop Service method to stop the CIM services.
cc.invokeMethod(ci, "StopService", null, null);
}
}