2
votes

I need the ability to look for another running process that is in the background while my NSIS installer is executing. This other process must be terminated and uninstalled before the new installer is completed.

I've tried using the FindProc plugin to find the process and also the KillProc plugin to kill the process. Each of those plug-ins returns nothing as a result.

FindProcDLL::FindProc "MyApplication.exe"

KillProcDLL::KillProc "MyApplication.exe"

I also tried nsProcess plug-in and it also does not work.

nsProcess::_KillProcess "MyApplication.exe" $R0

It seems people have success with these plug-ins but I don't know why it's not working in my scenario unless it has something to do with background processes.

Any help would be appreciated.

3
Anything special about this application? 64-bit? Running as a different user? A service? - Anders
It's a 32 bit application. It's running as the same user that's attempting to remove it. It's a WPF application that is running in the system tray, so there's a possibility that no physical Window exists. - John Murphy
If it has a tray icon it must have a window but it should not matter to the plug-in. Does it work with other apps like Notepad.exe? - Anders
Using nsProcess::_KillProcess "Notepad.exe" $R0 did not work. I am also outputting the value of $R0 in a MessageBox and the value of $R0 is empty, as in no value whatsoever. - John Murphy
A plugin cannot write to a register when it is provided as a parameter like that. - Anders

3 Answers

5
votes

None of the NSIS plug-ins I tried worked. They would all return no result (not even 0 or a negative number). I ended up just using the following command and it worked with no problems. It will briefly pop up a command window, but I am okay with this in my scenario:

ExecWait "TaskKill /IM MyApplication.exe /F"

Hope this helps someone else.

1
votes

Without knowing exactly which NSIS version you are using nor if you are compiling a Unicode or ANSI installer it is a bit hard to say exactly what's going on.

The original version from the wiki only works on 32-bit processes and the hnedka version should support 64-bit processes as well.

If you are using the hnedka version and NSIS v2.x then you need to extract the plug-in from the ANSI folder to \NSIS\Plugins. If you are using NSIS v3 then you need to extract from the ANSI folder to \NSIS\Plugins\x86-ansi and from the Unicode folder to \NSIS\Plugins\x86-unicode.

I can confirm that that hnedka version works in NSIS v3. If $R0 is empty then perhaps you extracted the wrong plug-in .dll to the wrong folder.

0
votes

Apparently you are trying to find and kill a x64 process which is not supported. You should check this link out http://nsis.sourceforge.net/Processes_plug-in