lothos12345 Posted April 15, 2005 Posted April 15, 2005 Is there a way in VB to kill a running process on a computer from a VB application, that infact has nothing to do with the application. For example if you have the internet open the process is "IEXPLORE.EXE" and I want to kill that process with a click of a button on a vb windows form. Is there a way to accomplish this and if so how? Any help given is greatly appreciated. Quote
HJB417 Posted April 15, 2005 Posted April 15, 2005 Use the Process Class. c# code static void KillProcesses() { System.Diagnostics.Process[] proccesses = System.Diagnostics.Process.GetProcessesByName("IEXPLORE"); try { foreach(System.Diagnostics.Process process in proccesses) process.Kill(); } finally { foreach(System.Diagnostics.Process process in proccesses) { try { process.Dispose(); } catch { } } } } decompiled as vb private static void KillProcesses() { Process[] processArray1 = Process.GetProcessesByName("IEXPLORE"); try { Process[] processArray2 = processArray1; for (int num1 = 0; num1 < processArray2.Length; num1++) { Process process1 = processArray2[num1]; process1.Kill(); } } finally { Process[] processArray3 = processArray1; for (int num2 = 0; num2 < processArray3.Length; num2++) { Process process2 = processArray3[num2]; try { process2.Dispose(); } catch { } } } } Quote
Leaders snarfblam Posted April 15, 2005 Leaders Posted April 15, 2005 Thats... decompiled to C#. Try this: Sub KillProcesses() Dim Proccesses As System.Diagnostics.Process() = _ System.Diagnostics.Process.GetProcessesByName("IEXPLORE") Try For Each Process As System.Diagnostics.Process In Proccesses Process.Kill() Next Catch Finally For Each Process As System.Diagnostics.Process In Proccesses Try Process.Dispose() Catch End Try Next End Try End Sub Quote [sIGPIC]e[/sIGPIC]
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.