This is a follow up to a previous question.
I am writing an NSIS installer that first checks if the app has already been installed and prompts the user to uninstall before proceeding.
The problem is that (whether or not uninstaller is run silently or otherwise) Windows will delete the previous uninstaller on reboot. And in the case where the previous and current uninstallers have the same name and are installed in the same location Windows will delete the current uninstaller assuming that it is the new one, even if the old uninstaller has been manually deleted as shown below:
; $R0 is the full path to the uninstall application.
ReadRegStr $R0 HKLM "SoftwareMicrosoftWindowsCurrentVersionUninstall${APPNAME}" "UninstallString"
; $R1 is the install direction of the exiting installation of Besso.
ReadRegStr $R1 HKLM "SoftwareMicrosoftWindowsCurrentVersionUninstall${APPNAME}" "InstallLocation"
ExecWait '$R0 /S _?=$R1' ; silent uninstall deletes new installer
;ExecWait '$R0 _?=$R1' ; non-silent uninstall also deletes the new installer.
Delete $R0 ; manually delete uninstaller
What would the best way to solve this problem? I am considering
- Copying the previous uninstaller to the TEMP directory and running it from there, or
- Renaming the previous uninstaller before running it.