Kill a process

Hi,
Could someone show me an example on how to kill a process. It needs to work on 9x and NT.
The process I would like to kill is aim.exe "which is AOL Instant Messenger"

Thanks
RCILLAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
crystalbyConnect With a Mentor Commented:
This part needs to be in the module
*************************************
Option Explicit

Public Declare Function TerminateProcess _
  Lib "kernel32" (ByVal hProcess As Long, _
  ByVal uExitCode As Long) As Long

Public Declare Function FindWindow _
  Lib "user32" Alias "FindWindowA" _
  (ByVal lpClassName As String, _
  ByVal lpWindowName As String) As Long

Public Declare Function PostMessage _
  Lib "user32" Alias "PostMessageA" _
  (ByVal hwnd As Long, ByVal wMsg As Long, _
  ByVal wParam As Long, ByVal lParam As Long) As Long

Public Const WM_CLOSE = &H10
Public Const PROCESS_ALL_ACCESS = &H1F0FFF

Public Declare Function GetWindowThreadProcessId _
  Lib "user32" (ByVal hwnd As Long, _
  lpdwProcessId As Long) As Long

Public Declare Function OpenProcess Lib "kernel32" _
  (ByVal dwDesiredAccess As Long, ByVal bInheritHandle _
  As Long, ByVal dwProcessId As Long) As Long

******************************


This part is in the form.
*******************************
Option Explicit

Private Sub Command1_Click()
  Dim hwnd As Long
  Dim ProcessId As Long
  Dim hProcess As Long
  Dim TermSucc As Boolean
 
  hwnd = FindWindow("Notepad", vbNullString)
 
  GetWindowThreadProcessId hwnd, ProcessId
 
  hProcess = OpenProcess(PROCESS_ALL_ACCESS, True, ProcessId)
  TermSucc = TerminateProcess(hProcess, 0)
 
  'PostMessage hwnd, WM_CLOSE, 0&, 0&
End Sub
*******************************

That's the code to kill NotePad.exe
0
 
fluglashCommented:
API call TerminateProcess
0
 
MUPPETCommented:
use the command kill aim.exe from the command line, if kill not installed download of microsoft
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
CleanupPingCommented:
RCILL:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
0
 
DanRollinsCommented:
Moderator, my recommended disposition is:

    Accept crystalby's comment(s) as an answer.

DanRollins -- EE database cleanup volunteer
0
All Courses

From novice to tech pro — start learning today.