?
Solved

Kill a process

Posted on 2003-02-25
7
Medium Priority
?
307 Views
Last Modified: 2010-05-01
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
0
Comment
Question by:RCILL
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 7

Expert Comment

by:fluglash
ID: 8015249
API call TerminateProcess
0
 

Expert Comment

by:MUPPET
ID: 8015349
use the command kill aim.exe from the command line, if kill not installed download of microsoft
0
 

Accepted Solution

by:
crystalby earned 400 total points
ID: 8020840
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Expert Comment

by:CleanupPing
ID: 8901164
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
 
LVL 49

Expert Comment

by:DanRollins
ID: 8972735
Moderator, my recommended disposition is:

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

DanRollins -- EE database cleanup volunteer
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question