' Monitor process stop trace events.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessStopTrace = objWMIService.ExecNotificationQuery _
("SELECT * FROM Win32_ProcessStopTrace")
WScript.Echo "Waiting for process to stop ..."
Do
Set objLatestEvent = colProcessStopTrace.NextEvent
WScript.Echo
Wscript.Echo "Process Name: " & objLatestEvent.ProcessName
Wscript.Echo "Process ID: " & objLatestEvent.ProcessId
Wscript.Echo "Time: " & objLatestEvent.TIME_CREATED
'Property is new for Windows Server 2003.
Wscript.Echo "Exit Code: " & objLatestEvent.ExitStatus
Loop