Code
Set Events = GetObject("winmgmts:\\.\root\cimv2").ExecNotificationQuery("SELECT TargetInstance.Name FROM __InstanceDeletionEvent WITHIN 5 WHERE TargetInstance ISA 'Win32_Process' AND TargetInstance.Name = 'cmd.exe'")
Do
Set TerminationEvent = Events.nextevent
WScript.Echo "程序 " & TerminationEvent.TargetInstance.Name & "已终止运行. "
Loop
Set Events = GetObject("winmgmts:\\.\root\cimv2").ExecNotificationQuery("SELECT TargetInstance.Name FROM __InstanceDeletionEvent WITHIN 5 WHERE TargetInstance ISA 'Win32_Process' AND TargetInstance.Name = 'cmd.exe'")
Do
Set TerminationEvent = Events.nextevent
WScript.Echo "程序 " & TerminationEvent.TargetInstance.Name & "已终止运行. "
Loop