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

Open in new window

dllhostime.PNG
LVL 1
celticianAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MacroShadowCommented:
In not sure about the CPU time, but you can get the PercentProcessorTime easily (just change XXXX to the pid of your process):
for each Process in GetObject("winmgmts:{impersonationLevel=impersonate}//localhost").ExecQuery("Select PercentProcessorTime,IDProcess from Win32_PerfFormattedData_PerfProc_Process where IDProcess=XXXX")
    WScript.Echo(Process.PercentProcessorTime)
    WScript.quit  
next

Open in new window

0
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
If you want "CPU time", you'll need to add KernerModeTime and UserModeTime, then divide by 1e7 (100 nanoseconds). The unit is not milliseconds as stated in your code.
CPUSecs = (CSng(objProcess.KernelModeTime) + CSng(objProcess.UserModeTime)) / 10000000

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
celticianAuthor Commented:
Os its that the time we can see in the task manager?
0
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
Yes,  this should show exactly the same value in VBS and in Task Manager.
0
Martin LissOlder than dirtCommented:
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.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.