Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Terminate Process

Status
Not open for further replies.

tnayfeh

Programmer
Apr 21, 2004
39
CA
I have the following code that is used to kill a process knowing the PID on my local machine. Would it be hard to change this code to kill processes on another machine, presuming they have administrative rights of course.

Code:
Option Compare Database

Option Explicit

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

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

Private Declare Function CloseHandle Lib "kernel32" _
(ByVal hObject As Long) As Long

Private Const PROCESS_TERMINATE As Long = &H1


Private Sub Command1_Click()
Dim ProcHandle As Long
  ProcHandle = OpenProcess(PROCESS_TERMINATE, False, CLng(236))
  TerminateProcess ProcHandle, 0
  CloseHandle ProcHandle
End Sub

Thanks in advance!
TN
 
Just kill any old process on the target or is there something in particular you wish to kill?
 
Sheco,
I am trying to kill a specific process (on another machine) by passing it the PID.

Thanks,
TN
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top