1

In my .nsi file I have the following logic in the un.onInit function:

Function un.onInit

  MessageBox MB_YESNO "This will uninstall. Continue?" IDYES checkRunning
  checkRunning:
    FindProcDLL::FindProc "app.exe"
    IntCmp $R0 1 0 notRunning
    MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION "${PRODUCT} is running, please close it so the installation can proceed." /SD IDCANCEL IDRETRY checkRunning
    Abort

  notRunning:
    !insertmacro Init "uninstaller"
FunctionEnd

However, the messageBox (and the process is running message) is never shown. So I went through a lot of documentation and apparently running silent mode prevents this method being called so I added SilentInstall normal and SilentUnInstall normal to the .nsi file. However, this doesn't work either.

I tried invoking the uninstaller by manually going to the uninstall.exe and by running the installer which checks if there is already a version installed and if there is calling:

uninst:
    ClearErrors
    ExecWait '$R0 _?=$INSTDIR' ;Do not copy the uninstaller to a temp file
    ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT}" "UninstallString"
    StrCmp $R0 "" done
    Abort

Yet both of these invokes do not trigger to 'normal' mode. So how can I get my un.onInit function to be called?

Edit:

As someone asked for the whole file, here it is. I copied the relevant parts only, but if more is needed feel free to check it out. Note that the whole file is already quite old, I am merely updating it.

Gooey
  • 4,740
  • 10
  • 42
  • 76
  • Can you post the entire .nsi file here. Call order sometimes effect "native" nsi methods. Also, "nsProcess.nsh" is what I use to check for the running application; I am not saying this is the issue here, but I have not seen `FindProcDLL` used for this before... – MoonKnight Mar 15 '16 at 11:12
  • @Killercam check the edit – Gooey Mar 15 '16 at 12:30
  • I'm curious if the behaviour changes when using `un.onGUIInit` instead – idleberg Mar 15 '16 at 14:06
  • @idleberg I just tried and unfortunately it doesn't trigger either. Even though this function is not meant for aborting (afaik) it is a good suggestion. – Gooey Mar 16 '16 at 13:08

1 Answers1

1

After upgrading the MUI2 (Modern User Interface 2.0), downgrading to NSIS 2.5 and using the NsProcess plug-in, I got it working. The function is now being called and my check works using the new plugin. The FindProcDLL plugin is broken on NSIS > 2.46

Gooey
  • 4,740
  • 10
  • 42
  • 76
  • This does not explain why there is no messagebox! Your version numbers are also confusing me, there is no 2.4.6. There is 2.46. The unofficial fork has 2.46.x versions but you should be using NSIS 3 instead if you want those features present there. – Anders Mar 17 '16 at 16:17