Process Kill

lothos12345

Junior Contributor
Joined
May 2, 2002
Messages
294
Location
Texas
i have written a visual basic.net 2003 application and upon it closing I want it to kill all instances of the application that are running, so I used the code below

Dim proc() as Process
proc = Process.GetProcessesByName("AppName")

For Each SingleProcess as Process in Proc
SingleProcess.Kill
Next


The above code works generally well but there are occasions when it will not close all instances of the application and I am not sure why. If anyone can shed some light as to the reason, it would be greatly appreiciated.

Thanks
 
Just a question? Why are you killing the processes instead of simply closing them, i.e.
Visual Basic:
SingleProcess.CloseMainWindow()
 
PlausiblyDamp said:
If you are killing all instances of the application - think about what will happen if this loop kills itself before the remaining instances are killed.....


You were absolutely correct it was killing itself before the it killed the other instances. Thanks for your help.
 
Back
Top