NSIS silent installs don't have a default set for uninstaller message box
In the NSIS.template.in
file, the following section of code checks for an existing install and asks the user if they want to remove it before installing the new version:
Function .onInit
StrCmp "@CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL@" "ON" 0 inst
ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "UninstallString"
StrCmp $0 "" inst
MessageBox MB_YESNOCANCEL|MB_ICONEXCLAMATION \
"@CPACK_NSIS_PACKAGE_NAME@ is already installed. $\n$\nDo you want to uninstall the old version before installing the new one?" \
IDYES uninst IDNO inst
Abort
In the above call to MessageBox
, there is no /SD parameter to set a default to be used for silent installs. This should probably default to answering YES to allow the new install to replace the old one. Something like the following should work:
MessageBox MB_YESNOCANCEL|MB_ICONEXCLAMATION \
"@CPACK_NSIS_PACKAGE_NAME@ is already installed. $\n$\nDo you want to uninstall the old version before installing the new one?" \
/SD IDYES IDYES uninst IDNO inst
Relevant documentation can be found here, but a clearer explanation is in the example that documentation links to.