+ ;Uninstall the old version, if present
+ ReadRegStr $R0 HKLM \
+ "Software\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" \
+ "UninstallString"
+ StrCmp $R0 "" inst
+
+ MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
+ "$(^Name) is already installed. $\n$\nClick `OK` to remove the \
+ previous version or `Cancel` to cancel this upgrade." \
+ IDOK uninst
+ Abort
+
+uninst:
+ ;Run the uninstaller
+ ClearErrors
+ ExecWait '$R0 _?=$INSTDIR' ;Do not copy the uninstaller to a temp file
+
+ ;IfErrors no_remove_uninstaller
+ ; ;You can either use Delete /REBOOTOK in the uninstaller or add some code
+ ; ;here to remove to remove the uninstaller. Use a registry key to check
+ ; ;whether the user has chosen to uninstall. If you are using an uninstaller
+ ; ;components page, make sure all sections are uninstalled.
+ ;no_remove_uninstaller:
+
+ Goto done
+inst:
+
+ ; install the new version