Search code examples
processnsis

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.


Solution

  • 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.