Tech Support banner

Status
Not open for further replies.
1 - 2 of 2 Posts

·
Registered
Joined
·
12 Posts
Discussion Starter #1
Hi guys :)

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
This is something i found on the internet:

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
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 :D
 
1 - 2 of 2 Posts
Status
Not open for further replies.
Top