[1] Killing a process is easier than terminating a service. You can just retrieve a reference to it via querying the known property, .name in your case say, and then issue .terminate() method.
[2] For more than one instance running at the same time, you then retrieve the collection of the named processes. From each process in the collection, you determine the .pid of each individually. From pid you differentiate everyone instance of them.
[3] From each process (with the definite pid), you check out each instance of win32_PerfRawData_PerfProc_Process. From this reference, invoke the .PercentProcessorTime.
[4] For each percentprocesstime exceeding a given 15% say, you terminate that process with that pid.
This is the sketch you have to make. But, you know, sampling one time instance does not make much sense in this business. You might have to consider sampling quite a number, at least 2, with the average exceeding the limit to trigger the kill. Use wscript.sleep to get successive sampling points.
Hope the above can help you to identify the elements needed and to implementing the code.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.