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!

Kill process in Windows

Status
Not open for further replies.

tnayfeh

Programmer
Apr 21, 2004
39
CA
Hi All,
I have a program within Access that populates a table with the PID session number and program name for a specific process on the server.

Is is possible to kill a process using code?

For example I would like a simple form that would have a pop up or text box to enter the PID number and it would automatically kill that process.
I know it's a risky procedure but I just found out that it's a trial and error way that they're killing processes on the server right now.

Thanks in advance!
TN
 
this will involve the Win32API's regarding threads and processes. Check out the KB and MSDN at Microsoft.
hth
steve
 
I have tried this code within a function in Access but can't seem to compile as it doesn't understand the objProcess.Terminate statement below. Am I missing something here?

Code:
Option Explicit

Dim objWMIService, objProcess, colProcess
Dim strComputer, strProcessKill
Dim intPID

  Set strComputer = "."
  Set intPID = InputBox("Enter the PID")

   Set objWMIService = GetObject("winmgmts:" _
   & "{impersonationLevel=impersonate}!\\" _ 
   & strComputer & "\root\cimv2") 

   Set colProcess = objWMIService.ExecQuery _
   ("Select * from Win32_Process Where ProcessID = " & intPID)

    For Each objProcess in colProcess
     objProcess.Terminate()
    Next

    WSCript.Echo "Just terminated process " & intPID _
    & " on " & strComputer
    WScript.Quit
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top