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 on another machine

Status
Not open for further replies.

tnayfeh

Programmer
Apr 21, 2004
39
CA
Hi,
I'm using the code below to kill a process on my local machine by passing it the PID. I would like to terminate a process on another machine using the computer name. Is there a way to specify computer name somewhere? (I do have administrative rights on the other machine)

Thanks in advance,
TN

Code:
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
  Dim PID As Int

  ProcHandle = OpenProcess(PROCESS_TERMINATE, False, CLng(PID))
  TerminateProcess ProcHandle, 0
  CloseHandle ProcHandle

End Sub
 
What are the operating systems involved? If you have 2k+ then you can use WMI to do this.
 
Yes they are Win2k machines. How would I use WMI, I'm not familiar with it.

Thanks,
TN
 
Check out this thread222-1097579

It doesn't actually call the terminate method but will provide you with sufficient code to begin with.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top