Link to home
Start Free TrialLog in
Avatar of Nadeemj
Nadeemj

asked on

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
thnks
Avatar of amyhxu
amyhxu

       Dim AllProcesses As Process() = Process.GetProcesses
        For Each p As Process In AllProcesses
            p.Kill()
        Next
ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start 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
            proc.Kill()
        End If
    Next
---
In your case, you would use GetProcesses() instead of GetProcessesByName().
Avatar of Nadeemj

ASKER

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

thnks