' Monitor process deletion event
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 be terminated ..."
Set objLatestEvent = colMonitorProcess.NextEvent
Wscript.Echo VbCrLf & "Process Name: " & objLatestEvent.TargetInstance.Name
Wscript.Echo "Process ID: " & objLatestEvent.TargetInstance.ProcessId
WScript.Echo "Time: " & Now