Traps process deletion events and gets start and stop times for process. Press Ctrl+C to end script.

Visual Basic
Edit|Remove
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 a process to stop ..."
Do
  Set objLatestEvent = colMonitorProcess.NextEvent
  WScript.Echo VbCrLf & objLatestEvent.Path_.Class
  Wscript.Echo "Process Name: " & objLatestEvent.TargetInstance.Name
  Wscript.Echo "Process ID: " & objLatestEvent.TargetInstance.ProcessId
  Wscript.Echo "Time Created: " & _
   objLatestEvent.TargetInstance.CreationDate
  WScript.Echo "Time Deleted: " & Now
Loop