When running the uninstaller normally, a custom page is displayed (Using the MUI) informing the user that they need to exit the application before continuing. This works as expected.
However, if the uninstaller is run silently, it should abort during the initialization phase. This is NOT working as expected. Every time I run the uninstaller silently, it will continue with the uninstallation process regardless of whether the application is currently in use or not.
The following is a simplified version of my uninstaller:
Note that the "FindProc" call only returns a value of "1" if the application can definitely be determined to be in use.
!insertmacro MUI_UNPAGE_WELCOME
UninstPage CUSTOM un.ApplicationInUse_EnterPage un.ApplicationInUse_ExitPage
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
Section "Uninstall"
; These instructions are reused by "onInstFailed"
!include "Uninstallation.nsi"
SetAutoClose TRUE
SectionEnd
Function un.onInit
IfSilent +3 0
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "CustomPage.ini"
GoTo End
FindProcDLL::FindProc "MyApplication.exe"
Pop $R0
${If} $R0 == 1
Abort
${EndIf}
End:
FunctionEnd
Function un.ApplicationInUse_EnterPage
FindProcDLL::FindProc "MyApplication.exe"
Pop $R0
${If} $R0 == 1
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "CustomPage.ini"
${EndIf}
FunctionEnd
Function un.ApplicationInUse_ExitPage
Quit
FunctionEnd
So, the question is, what's the problem? The script being used in the "un.onInit" and "un.ApplicationInUse_EnterPage" functions is the same, yet only the latter works as expected.