Jump to content

cbox


Recommended Posts

Posted (edited)

You can kill a process in several ways, by using the process's Name, ID, Handle, MainWindowTitle, and more. The following sample will show you how to kill a process using the processes name and main window title. Error handling is provided to make sure it doesn't throw a False when it tries to kill a SYSTEM process.

 

 

Public Function KillProcess(ByVal procName As String) As Boolean

   For Each p As Process In Process.GetProcesses
       If p.ProcessName.StartsWith(procName) Then
           Try
               p.Kill()
           Catch
           End Try
       ElseIf p.MainWindowTitle.StartsWith(procName) Then
           Try
               p.Kill()
           Catch
           End Try
       End If
   Next
   Return (True)
End Function

'Usage'
KillProcess("explorer")

Edited by iBotPeaches
  • Like 1
  • 3 months later...

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...