celtician
asked on
VBS script not retrieving process correct CPU memory time - Win 2000
This script gets the time when the process is created first (early in the morning,as these process are reset manually every day at 5.50 am), but i need to get the CPU time in the task bar (see picture please). It seems these are different times:
Option Explicit
Dim procDateCreate, strComputer, strProcessKill,objWMIService,colProcess,objProcess,TimeToKill,mustKill
strComputer = "."
strProcessKill = "'dllhost.EXE'"
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcess = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = " & strProcessKill )
For Each objProcess in colProcess
TimeToKill = DateAdd("n",4,WMIDateStringToDate(objProcess.CreationDate))
WScript.Echo "proc Name: " & objProcess.name
WScript.Echo "proc CreationDate: " & objProcess.CreationDate
WScript.Echo "proc CreationDate (Human): " & WMIDateStringToDate(objProcess.CreationDate)
WScript.Echo "proc CreationDate + 2minutes: "& TimeToKill
If DateDiff("s",TimeToKill,WMIDateStringToDate(objProcess.CreationDate))<0 Then
mustKill = 1
End If
WScript.Echo "hay que matar:"
WScript.Echo mustKill
WScript.Echo "proc KernelModeTime (Milliseconds): "& objProcess.KernelModeTime
WScript.Echo "proc UserModeTime (Milliseconds): "& objProcess.UserModeTime
Next
Function WMIDateStringToDate(dtmStart)
WMIDateStringToDate = CDate(Mid(dtmStart, 5, 2) & "/" & _
Mid(dtmStart, 7, 2) & "/" & Left(dtmStart, 4) _
& " " & Mid (dtmStart, 9, 2) & ":" & _
Mid(dtmStart, 11, 2) & ":" & Mid(dtmStart, _
13, 2))
End Function
dllhostime.PNG
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Os its that the time we can see in the task manager?
Yes, this should show exactly the same value in VBS and in Task Manager.
I've requested that this question be closed as follows:
Accepted answer: 500 points for Qlemo's comment #a40921374
for the following reason:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
Accepted answer: 500 points for Qlemo's comment #a40921374
for the following reason:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
Open in new window