How to kill a process?

Sep 7, 2009 at 1:43pm
I know the program name to be killed, such as 'UpdateUI.exe'.

How could I found the 'UpdateUI.exe' and killed the program?
Sep 7, 2009 at 4:20pm
Use TerminateProcess(): http://msdn.microsoft.com/en-us/library/ms686714%28VS.85%29.aspx.

That one requires a handle to the process. You can get a handle by using OpenProcess(): http://msdn.microsoft.com/en-us/library/ms684320%28VS.85%29.aspx.

OpenProcess(), in turn, requires the process ID. You can get the process ID by enumerating the currently running processes. Once you find a match for "UpdateUI.exe", then you can OpenProcess() and then TerminateProcess().

To learn how to enumerate processes, read the topic about the CreateToolhelp32Snapshot() at MSDN: http://msdn.microsoft.com/en-us/library/ms682489%28VS.85%29.aspx.
Sep 8, 2009 at 11:50am
It's easy.

HANDLE tmpHandle = OpenProcess(PROCESS_ALL_ACCESS, TRUE, dwProcessID);
if (NULL != tmpHandle)
{
TerminateProcess(tmpHandle, 0);
}

But you must know the process ID.

And you know the process name,
you can get the process id
Sep 8, 2009 at 1:41pm
easy
,in CMD mode, it's easy for you to use "ntsd -c q -p pid ",and you could terminate any process in ring3 level.
Sep 8, 2009 at 2:39pm
phikaa, since I'm not familiar with the command you post, I assume that it is for Linux/Unix? If so, please note that the topic is under the "Windows Programming" forum.
Sep 8, 2009 at 4:25pm
ntsd is the symbolic debugger and is irrelevant here.
Sep 8, 2009 at 11:34pm
It isn't irrelevant -- it answers the OP's question: how do I kill a process?

It does require you to start a new process (the ntsd.exe) and it also requires you to know the PID of the process to kill...

However, if you are going to use the command prompt, you can also use the taskkill Windows utility, which gives a few more options for selecting which process(es) to kill. (Works with XP and later.)
Sep 8, 2009 at 11:38pm
Being this a C++ forum, I'd say a command-line solution is irrelevant. When someone asks a question in these forums, I think it is expected to do it via C++.
Oct 2, 2009 at 6:20am
You can find the PID of a process using its process name grammatically. Read this article from FrostCode

http://www.frostcode.info/common-articles/get-pid-from-process-name.html

Then, use TerminateProcess() to kill process.
Last edited on Oct 2, 2009 at 6:27am
Oct 2, 2009 at 9:50am
Stop your spamming on all forums with your BS 'frostcode' : its only complete newbie and horrible pseudo-code
Read MSDN for the right method to get the PID
Read the Petzold to learn Windows programming .
Topic archived. No new replies allowed.