473,421 Members | 1,595 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,421 software developers and data experts.

kill process

hi, im been working on a process manager for awhile and i cant find anywhere
how to kill a running process....any help would b awsome
--
-iwdu15
Nov 23 '05 #1
4 3278
Process.Kill() method
or
TerminateProcesS() Win32 API function.

"iwdu15" <iw****@discussions.microsoft.com> wrote in message
news:B2**********************************@microsof t.com...
hi, im been working on a process manager for awhile and i cant find anywhere
how to kill a running process....any help would b awsome
--
-iwdu15
Nov 23 '05 #2
yes, but what parameters do i gve it?
Nov 23 '05 #3
Process.Kill() kills the process represented by the current Process
instance. Process instance for the running processes could be obtained using
Process.GetProcesses().

For TerminateProcess(), pass the Process.Handle (obtained using
GetProcesses()) and an exit code.

"iwdu15" <iw****@discussions.microsoft.com> wrote in message
news:6B**********************************@microsof t.com...
yes, but what parameters do i gve it?
Nov 23 '05 #4

"iwdu15" <iw****@discussions.microsoft.com> schrieb im Newsbeitrag
news:6B**********************************@microsof t.com...
yes, but what parameters do i gve it?

Hi iwdu15,

a few years ago i wrote a procedure in C to kill processes:
#include "stdafx.h"
#include "endprog.h"
void main()
{
kill("proc1.exe");
kill("proc2.exe");
#ifdef _DEBUG
printf("Press Enter >");
_getch();
#endif
}
void kill(char* fName)
{ DWORD dProcID=0;
HWND hWnd=0;
while (dProcID=FindProcessID(fName))
{
HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, dProcID);
#ifdef _DEBUG
printf("Process %x;PID %u \n",hProcess,dProcID);
#endif
if(hProcess)
TerminateProcess(hProcess,0);
#ifdef _DEBUG
printf("%s killed \n",fName);
#endif
}
}
DWORD FindProcessID(char* szProcessName)
{
DWORD aProcesses[1024], cbNeeded, cProcesses;
unsigned int i;
if(!EnumProcesses(aProcesses,sizeof(aProcesses),&c bNeeded)) return 0;
cProcesses = cbNeeded/sizeof(DWORD);
for(i=0;i<cProcesses;i++)
{
if (CompareProcessNameandID( aProcesses[i],szProcessName))
return aProcesses[i];
}
return 0;
}
BOOL CompareProcessNameandID(DWORD processID, char* szSearchName)
{
char szProcessName[MAX_PATH] = "unknown";
HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION |
PROCESS_VM_READ, FALSE, processID);
if (hProcess)
{
HMODULE hMod;
DWORD cbNeeded;
if(EnumProcessModules(hProcess,&hMod,sizeof(hMod), &cbNeeded))
GetModuleBaseName(hProcess,hMod,szProcessName,size of(szProcessName));
}
CloseHandle(hProcess);
return !_stricmp(szProcessName,szSearchName);
}

May be helpfull
B.R.
Klaus
Nov 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Bob Swerdlow | last post by:
My application starts up a number of processes for various purposes using: self.popen = popen2.Popen3("/usr/local/bin/python -O "myscript.py") and then shuts them down when appropriate with...
10
by: Fred | last post by:
There is a setting in INIT.ORA that has the unintended side-effect of making sure the ALTER SYSTEM KILL SESSION command has immediate affect. Without this setting, I've seen some instances where...
10
by: Jako Menkveld | last post by:
I'm building a relatively simple client-server app. One of the functions of the client is to notify the server when it terminates, this all works fine. The problem comes in when the server is...
3
by: pattanawadee | last post by:
Deall All, Could anybody suggestion me How to kill all inherrit processes (sibling child,previous and parent process) in the case I know only child process id and user id, For example I strart...
6
by: Matthew Wieder | last post by:
What permissions must a user have to be able to succesffuly execute a Process.Kill? I can run it with Admin privleges but not with regular user priveleges - I get an "Access is Denied." The...
0
by: WATYF | last post by:
This is my problem... I have some code that starts a Process and returns it to a variable... (prcBat) At any time while that process is running... I want to be able to Kill it by pressing a...
5
by: Dino Buljubasic | last post by:
My application can allow a user to open a file for viewing by fetching file data from database, creating the file in a temp directory and starting appropriate process (i.e. Adobe or any other...
3
by: elrondrules | last post by:
Hi Am new to python and need your help!! this is my code snip. within my python script I have the following commands.. <snip> import os
4
by: Richard Rossel | last post by:
Hi Fellows, I have a problem with process termination. I have a python code that apache runs through a django interface. The code is very simple, first, it creates a process with the...
2
by: =?Utf-8?B?WVhR?= | last post by:
Hello, In the parent process(A), run update function, and start the update process(B), in B process, kill A, then download and update files, then restart A. I want to know can the B process kill...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.