Joined
·
12 Posts
Hi guys 
i am making a scriptfor myself, where somethling like this happens:
This is something i found on the internet:
However the problem with the code above is that it stops at colProcess.NextEvent, while i want it to loop UNTIL it is closed.
Is it possible to do something like that?
Let me know.
P.S.
I am new here and i must say this is a very nice place
i am making a scriptfor myself, where somethling like this happens:
Code:
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecNotificationQuery("SELECT * FROM __InstanceCreationEvent WITHIN 2 WHERE TargetInstance ISA 'Win32_Process'")
Do
Set objNewProcess = colProcesses.NextEvent
If objNewProcess.TargetInstance.Name = "WINWORD.EXE" THEN
Do While ObjNewProcess Is Open
'Do something
Loop
End If
Loop
Code:
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colProcess = objWMIService.ExecNotificationQuery("SELECT * FROM __InstanceDeletionEvent WITHIN 2 WHERE TargetInstance ISA 'Win32_Process' AND TargetInstance.Name = 'notepad.exe'")
Set objNewProcess = colProcess.NextEvent
'Do something
Is it possible to do something like that?
Let me know.
P.S.
I am new here and i must say this is a very nice place