Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Programming and Hacking > Development

Reply
 
Thread Tools Display Modes
Old 21st November 2006, 15:54   #1  |  Link
Razorholt
Cyberspace Citizen
 
Razorholt's Avatar
 
Join Date: Nov 2005
Posts: 457
How to kill a process in NSIS?

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
Razorholt is offline   Reply With Quote
Old 21st November 2006, 17:15   #2  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Germany
Posts: 8,513
Like thus?

Code:
FindWindow $0 "<Window Name>"
SendMessage $0 ${WM_CLOSE} 0 0
LoRd_MuldeR is online now   Reply With Quote
Old 21st November 2006, 21:11   #3  |  Link
Razorholt
Cyberspace Citizen
 
Razorholt's Avatar
 
Join Date: Nov 2005
Posts: 457
Thanks man! Lemme see if it works... Will it also work with InnoSetup?

Cheers,
-Dan
Razorholt is offline   Reply With Quote
Old 21st November 2006, 21:33   #4  |  Link
Razorholt
Cyberspace Citizen
 
Razorholt's Avatar
 
Join Date: Nov 2005
Posts: 457
Just found a discussion on this subject here
Razorholt is offline   Reply With Quote
Old 22nd November 2006, 03:49   #5  |  Link
Razorholt
Cyberspace Citizen
 
Razorholt's Avatar
 
Join Date: Nov 2005
Posts: 457
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...
Razorholt is offline   Reply With Quote
Old 22nd November 2006, 18:51   #6  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Germany
Posts: 8,513
Quote:
Originally Posted by Razorholt View Post
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
Maybe you did not use it properly or you did not enter the right Window name...
LoRd_MuldeR is online now   Reply With Quote
Old 22nd November 2006, 21:20   #7  |  Link
Razorholt
Cyberspace Citizen
 
Razorholt's Avatar
 
Join Date: Nov 2005
Posts: 457
it only works in NSIS, correct?
Razorholt is offline   Reply With Quote
Old 22nd November 2006, 21:25   #8  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Germany
Posts: 8,513
Quote:
Originally Posted by Razorholt View Post
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...
LoRd_MuldeR is online now   Reply With Quote
Old 23rd November 2006, 01:55   #9  |  Link
Razorholt
Cyberspace Citizen
 
Razorholt's Avatar
 
Join Date: Nov 2005
Posts: 457
Alright, I got it now:
Code:
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
Razorholt is offline   Reply With Quote
Old 6th December 2006, 06:34   #10  |  Link
death2all
Registered User
 
Join Date: Jul 2005
Posts: 1
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.
death2all is offline   Reply With Quote
Old 6th December 2006, 07:33   #11  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Germany
Posts: 8,513
Quote:
Originally Posted by death2all View Post
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...
LoRd_MuldeR is online now   Reply With Quote
Old 7th December 2006, 19:08   #12  |  Link
Razorholt
Cyberspace Citizen
 
Razorholt's Avatar
 
Join Date: Nov 2005
Posts: 457
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
Razorholt is offline   Reply With Quote
Old 8th December 2006, 00:58   #13  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Germany
Posts: 8,513
Quote:
Originally Posted by LoRd_MuldeR View Post
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 is online now   Reply With Quote
Old 14th December 2006, 17:01   #14  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Germany
Posts: 8,513
Okay, here is my own attempt to make a NSIS plugin for killing processes:
http://mulder.dummwiedeutsch.de/pub/...2006-12-14.zip


Very simple to use:
Code:
Section
  StrCpy $0 "foo.exe"
  DetailPrint "Killing all processed called '$0'"
  KillProc::KillProcess
  DetailPrint "Killed $0 processes"
SectionEnd
LoRd_MuldeR is online now   Reply With Quote
Old 16th December 2006, 11:27   #15  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Germany
Posts: 8,513
Here is an updated version:
http://mulder.dummwiedeutsch.de/pub/...2006-12-16.zip

It is now possible to search for processes without killing them.

Last edited by LoRd_MuldeR; 16th December 2006 at 11:30.
LoRd_MuldeR is online now   Reply With Quote
Old 16th December 2006, 16:13   #16  |  Link
Razorholt
Cyberspace Citizen
 
Razorholt's Avatar
 
Join Date: Nov 2005
Posts: 457
Thanks man. Great job!

- Dan
Razorholt is offline   Reply With Quote
Old 16th December 2006, 17:16   #17  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Germany
Posts: 8,513
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/...2006-12-16.zip
LoRd_MuldeR is online now   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 15:40.


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.