Hi all need help

Hi All I need to make a program wich will detect all applications running for example in Taskmanager and close them or kill them.

I am using vb.net

Pls help
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

       Dim AllProcesses As Process() = Process.GetProcesses
        For Each p As Process In AllProcesses
Fernando SotoRetiredCommented:
Hi Nadeemj;

Using amyhxu code above will give you all processes on the system including system/OS process and the program which is running and reporting this info. Although it is the way to get the processes care must be taken in killing the processes. Here is a program which uses Process.GetProcesses but sends the info to a list box so that the processes can be selected to be killed.

Imports System.Diagnostics

Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()

        'This call is required by the Windows Form Designer.

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
            End If
        End If
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents lbProcess As System.Windows.Forms.ListBox
    Friend WithEvents btnDelProcesses As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.btnDelProcesses = New System.Windows.Forms.Button
        Me.lbProcess = New System.Windows.Forms.ListBox
        Me.btnDelProcesses.Location = New System.Drawing.Point(64, 232)
        Me.btnDelProcesses.Name = "btnDelProcesses"
        Me.btnDelProcesses.Size = New System.Drawing.Size(120, 23)
        Me.btnDelProcesses.TabIndex = 0
        Me.btnDelProcesses.Text = "Delete Selected"
        Me.lbProcess.Location = New System.Drawing.Point(8, 8)
        Me.lbProcess.Name = "lbProcess"
        Me.lbProcess.SelectionMode = System.Windows.Forms.SelectionMode.MultiSimple
        Me.lbProcess.Size = New System.Drawing.Size(272, 199)
        Me.lbProcess.TabIndex = 1
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(292, 273)
        Me.Name = "Form1"
        Me.Text = "Form1"

    End Sub

#End Region

    Private ProcHt As New Hashtable

    Private Sub btnDelProcesses_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles btnDelProcesses.Click

        For Each procName As String In lbProcess.SelectedItems
            CType(ProcHt(procName), Process).Kill()


    End Sub

    Private Sub Form1_Load(ByVal sender As Object, _
        ByVal e As System.EventArgs) Handles MyBase.Load


    End Sub

    Private Sub LoadProcess()

        Dim AllProcesses() As Process
        Dim localproc As Process
        AllProcesses = Process.GetProcesses


        For Each localproc In AllProcesses
            lbProcess.Items.Add(localproc.ProcessName & "-" & localproc.Id.ToString)
            ProcHt.Add(localproc.ProcessName & "-" & localproc.Id.ToString, _

    End Sub

End Class

I hope this is of some help

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
To kill an application process:

    Dim proc As System.Diagnostics.Process
    Dim pList() As Process
    pList = Process.GetProcessesByName("notepad")
    For Each proc In pList
        Dim resp As MsgBoxResult
        resp = MsgBox("Terminate " & proc.ProcessName & "?", MsgBoxStyle.YesNo, "Terminate?")
        If resp = MsgBoxResult.Yes Then
        End If
In your case, you would use GetProcesses() instead of GetProcessesByName().
NadeemjAuthor Commented:
Guys  I know how to get processes and kill them. What i dont know how to do is kil only the Appications listed in task manager, automaticaly without having to have the user choosing the application

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.