John Murphy
John Murphy

Reputation: 975

NSIS Detect running background process

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.

Upvotes: 3

Views: 3175

Answers (3)

John Murphy
John Murphy

Reputation: 975

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.

Upvotes: 8

fatih
fatih

Reputation: 182

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

Upvotes: 0

Anders
Anders

Reputation: 101656

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.

Upvotes: 1

Related Questions