b_avery@yahoo.c
29th April 2004 08:49 UTC
Killing a Process
I have a process on my machine which I need to kill off, I've tried:
System::Call 'user32::PostMessageA(i,i,i,i) i($0,${WM_CLOSE},0,0)'
SendMessage $0 "000E" 0 0 ; WM_GETTEXTLENGTH ????
SendMessage $0 "0002" 0 0 ; WM_DESTROY
SendMessage $0 "0082" 0 0 ; WM_NCDESTROY
SendMessage $0 "0111" "E141" 0 ; WM_AppExit
SendMessage $0 "16" 0 0 ; WM_CLOSE
But it does not working.
Speaking to the developer he says you need to kill the process, like if you use Task manager and End Task.
He has suggested using:
getwindowthreadprocessid
Anyone know how I can do this?
b_avery@yahoo.c
29th April 2004 09:17 UTC
I think the calls you need to make are (in order)
1) FindWindow
2) GetWindowThreadProcessID
3) OpenProcess with PROCESS_TERMINATE
4) TerminateProcess, try a big exit code
I can do the FindWindow okay.
But how do I implement them into NSIS?
deguix
29th April 2004 12:33 UTC
Not Tested:
!define PROCESS_TERMINATE 0x0001
FindWindow$0 "WindowClass"
>System::Call "User32::GetWindowThreadProcessId(i,*i)i(r0,.r0)"
>System::Call "Kernel32::OpenProcess(i,i,i)i (${PROCESS_TERMINATE}, 1, r0) .r0"
>System::Call "Kernel32::GetExitCodeProcess(i,*i)i (r0,.r1)"
>System::Call "Kernel32::TerminateProcess(i,i)i (r0,r1)"
evilO
29th April 2004 15:07 UTC
Hi :)
There is a nice plugin that just does everything for you : KillProcDll
It can be found here :
http://nsis.sourceforge.net/archive/download.php
evilO/Olive
b_avery@yahoo.c
30th April 2004 00:07 UTC
Many thanks, tested and working on 98, ME, 2000 and XP.
But the Kill Process fails on NT Workstation :-(
evilO
30th April 2004 08:17 UTC
Doh !! I didn't know that :eek: !
Well, sorry :( ...
evilO/Olive
rsegal
4th May 2004 17:08 UTC
You can also try nopey. Which is available in the archive here at the bottom.
http://nsis.sourceforge.net/archive/download.php
Killing processes is one of it's features.
deguix
4th May 2004 22:23 UTC
I'm impressed with my code posted above, I didn't test at that time (I was going to school) and it worked when I tested it now. It's rare to work when I don't test.
Takhir
10th June 2004 19:58 UTC
deguix
GetExitCodeProcess() in your script will always return STILL_RUNNING,
and next TerminateProcess() sets STILL_RUNNING as process exit code. Another words, after process was terminated and while process handle is not closed (CloseHandle()), any following GetExitCodeProcess() call will return STILL_RUNNING – little confusing situation :)