Jump to content

  •  

  • iBotModz CBox


    Photo

    (VB.NET) Kill Process


    • Please log in to reply
    2 replies to this topic

    #1 Dark Slipstream

    Dark Slipstream

      Blue Shadowz Owner

    • Members+

    • 2,829 posts
    • Joined: 19-April 08
    • Gender:Male
    • Location:Canada, ON

    Posted 11 May 2009 - 10:32 PM

    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, 14 February 2010 - 12:33 PM.


    #2 ixGAMEOVERxixx

    ixGAMEOVERxixx

      Private Grade 2

    • VIP

    • 478 posts
    • Joined: 27-October 08
    • Gender:Not Telling
    • Location:Custom Games

    Posted 15 August 2009 - 05:11 PM

    What about..

    Process.GetProcessesByName(TextBox1.Text).Length = 0
    Dim pProcess() As Process = System.Diagnostics.Process.GetProcessesByName(TextBox1.Text)

    For Each p As Process In pProcess
    p.Kill()
    Next

    ___
    http://vbnetsample.b...ll-process.html

    Edited by ixGAMEOVERxixx, 16 August 2009 - 07:40 AM.


    #3 360

    360

      Sergeant Grade 2

    • Donors

    • 373 posts
    • Joined: 28-June 09
    • Gender:Male

    Posted 15 August 2009 - 07:13 PM

    Nice post slip