View Full Version : How to kill a process in NSIS?
Razorholt
21st November 2006, 16:54
Hi,
I would like to add the "auto-update" feature to my sofware but for that I need to make sure that the running process is killed prior to the updates installation.
What would be the line(s) for my to add?
Thanks,
- Dan
LoRd_MuldeR
21st November 2006, 18:15
Like thus?
FindWindow $0 "<Window Name>"
SendMessage $0 ${WM_CLOSE} 0 0
Razorholt
21st November 2006, 22:11
Thanks man! Lemme see if it works... Will it also work with InnoSetup?
Cheers,
-Dan
Razorholt
21st November 2006, 22:33
Just found a discussion on this subject here (http://forums.indiegamer.com/showthread.php?t=4478)
Razorholt
22nd November 2006, 04:49
Lord_Mulder, "FindWindow" doesn't work :( I moved to Inno Setup now because it's easier than NSIS to implement it with Python. But still, no avail...
LoRd_MuldeR
22nd November 2006, 19:51
Lord_Mulder, "FindWindow" doesn't work :( I moved to Inno Setup now because it's easier than NSIS to implement it with Python. But still, no avail...
I use it, and it does work :sly:
Maybe you did not use it properly or you did not enter the right Window name...
Razorholt
22nd November 2006, 22:20
it only works in NSIS, correct?
LoRd_MuldeR
22nd November 2006, 22:25
it only works in NSIS, correct?
Getting a window handle via "FindWindow" and sending a WM_CLOSE message to this window via "SendMessage" are common Windows API calls. So they work everywhere. But I don't how to call those functions with InnoSetup, since I never used it before...
Razorholt
23rd November 2006, 02:55
Alright, I got it now:
const
WM_CLOSE = $0010;
function InitializeSetup: Boolean;
var
Wnd: HWND;
begin
Wnd := FindWindowByWindowName('<window name>');
if Wnd <> 0 then SendMessage(Wnd, WM_CLOSE, 0, 0);
Result := True;
end;
It works perfectly, with Inno Setup at least.
Thanks,
- Dan
death2all
6th December 2006, 07:34
If you still want to use nsis then you can use this: http://nsis.sourceforge.net/Processes_plug-in . Works flawlessly in all the setups I have used it in up to now.
LoRd_MuldeR
6th December 2006, 08:33
If you still want to use nsis then you can use this: http://nsis.sourceforge.net/Processes_plug-in . Works flawlessly in all the setups I have used it in up to now.
Thanks for information. This one looks usefull... :)
Razorholt
7th December 2006, 20:08
Thanks death2all. I'm trying to use NSIS instead of InnoSetup but the latter is easier to implement to my python script. I know that there is a nspython plugin for NSIS but I use Python 2.4 - the plugin supports 2.2 and 2.3 only :(
Cheers,
- Dan
LoRd_MuldeR
8th December 2006, 01:58
Thanks for information. This one looks usefull... :)
Unfortunately this plugin has a very bad method to specify the process that is to be killed. The docs say, that you enter the file name without .exe extension. But if I enter "MPUI" it will kill MPUI.exe as well as MPUI.2006-12-03.Full-Package.exe. Thus the installer will kill itself. That's not how I need it to work!
Guess I need to make my own plugin...
LoRd_MuldeR
14th December 2006, 18:01
Okay, here is my own attempt to make a NSIS plugin for killing processes:
http://mulder.dummwiedeutsch.de/pub/downloads/testing/NSIS-KillProcess.2006-12-14.zip
Very simple to use:
Section
StrCpy $0 "foo.exe"
DetailPrint "Killing all processed called '$0'"
KillProc::KillProcess
DetailPrint "Killed $0 processes"
SectionEnd
LoRd_MuldeR
16th December 2006, 12:27
Here is an updated version:
http://mulder.dummwiedeutsch.de/pub/downloads/testing/NSIS-KillProcesses.2006-12-16.zip
It is now possible to search for processes without killing them.
Razorholt
16th December 2006, 17:13
Thanks man. Great job!
- Dan
LoRd_MuldeR
16th December 2006, 18:16
1. Removed some unneeded references -> DLL size is now 1/2 of previous version
2. Added some (very brief) documentation
http://mulder.dummwiedeutsch.de/pub/downloads/testing/NSIS-KillProc-Plugin.2006-12-16.zip
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.