' Get duration of processes from events (Windows XP & Windows Server 2003 only)



strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colMonitorProcess = objWMIService.ExecNotificationQuery _
("SELECT * FROM __InstanceDeletionEvent " _
& " WITHIN 1 WHERE TargetInstance ISA 'Win32_Process'")
WScript.Echo "Waiting for process to stop ..."
Do
  Set objLatestEvent = colMonitorProcess.NextEvent
  Set objDateTime = CreateObject("WbemScripting.SWbemDateTime")
  Wscript.Echo vbCrLf & "Process Name: " & objLatestEvent.TargetInstance.Name
  Wscript.Echo "Process ID: " & objLatestEvent.TargetInstance.ProcessId
  objDateTime.Value = objLatestEvent.TargetInstance.CreationDate
  Wscript.Echo "Time created: " & objDateTime.GetVarDate
  WScript.Echo "Time deleted: " & Now
  intSeconds = DateDiff("s", objDateTime.GetVarDate, Now)
  WScript.Echo "Duration: " & intSeconds & " seconds"
Loop
search for scripts

VbsEdit contains all these sample scripts!


Download Now!



Download   Home   Scripts

Copyright © 2001-2024 adersοft