So far, I have figured out how to detect a previous installation of my software by reading the registry keys and checking if the directory exists. (Both documents are well described in the NSIS help file.) Now I want to force the user to specify a different directory if the application has previously been installed. (No need to force delete yourself, because previous versions just delete everything, including saved data).
As far as I can see, MUI2.nsh has predefined templates for a license, installation folder, progress indicator, etc. How to add verification at this point in the installer thread?
The update is a Tried Paul solution, but it does not work. At the top of the script, I declared
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE validateDirectory !insertmacro MUI_PAGE_DIRECTORY
for reference to this function:
Function validateDirectory ReadRegStr $R0 HKLM "SOFTWARE\Aadhaar Enrolment Client" "Installdir" Pop $R0 StrCmp $R0 $OUTDIR +1 +3 MessageBox MB_ICONSTOP|MB_OK 'The directory $OUTDIR already exists.Please choose a different directory.' Abort FunctionEnd
This function displays a message but does not interrupt. Moreover, if I click "back" on the directory selection page and go forward again, it will simply continue the installation.
source share