C
Courage
Philip said:<vbscript>
'Get % Processor Time for a process
'Connect to Local Machine
set wmi_service =
GetObject("winmgmts:{impersonationlevel=impersonate}!\root\cimv2")
sObjectPath = "Win32_PerfRawData_PerfProc_Process.Name=" & chr(34) &
"taskmgr" & chr(34)
wscript.echo sObjectPath
set perf_instance1 = wmi_service.get( sObjectPath )
N1 = perf_instance1.PercentProcessorTime
D1 = perf_instance1.TimeStamp_Sys100NS
while true
'Sleep for one second = 1000 ms
wscript.sleep(1000)
set perf_instance2 = wmi_service.get( sObjectPath )
N2 = perf_instance2.PercentProcessorTime
D2 = perf_instance2.TimeStamp_Sys100NS
' CounterType - PERF_100NSEC_TIMER
' Formula = ((N2 - N1) / (D2 - D1)) x 100
if ( 0 = (D2-D1) ) then
wscript.echo "divide by zero"
else
PercentProcessorTime = ((N2 - N1) / (D2 - D1)) * 100
wscript.echo "% Processor Time = " , PercentProcessorTime
end if
N1 = N2
D1 = D2
wend
set wmi_service = nothing
</vbscript>
This Code works great, just what I've been looking for.
The thing is, I'd like to do this using *"IDProcess"* and not by usin
*"Name"*.
Is this possible at all and if yes, how would I go about this
-
Courag