Archive: uninstall or continue before install


uninstall or continue before install

...some code...
InstallDir "$PROGRAMFILES\somewhere\"
...some code...
Section -Post
WriteUninstaller "$INSTDIR\uninstall.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninstall.exe"
SectionEnd

Function .onInit
ReadRegStr $R1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "UninstallString"
StrCmp $R1 "" done

MessageBox MB_YESNO|MB_ICONEXCLAMATION \
"${PRODUCT_NAME} is already installed. $\n$\nDo you want to remove \
the old installation before installing ${PRODUCT_NAME} ." \
IDNO done

;Run the uninstaller
ClearErrors
ExecWait '$R1 _?=$INSTDIR'
done:
FunctionEnd



Im installing application in different folder than InstallDir

Why when i run the installer ,and when he find that application is already installed uninstaller run from InstallDir instead from the place where application is already installed - $R1

if i add
ExecWait '$INSTDIR\uninstall.exe'
uninstaller is not found.

I guess im missing something ,but what :)

You're missing the fact that $INSTDIR is not yet initialized when running function .onInit

http://nsis.sourceforge.net/Docs/Chapter4.html#4.2.2


Thanks for the tips ,it all working fine now ,this post help me too

http://forums.winamp.com/showthread.php?postid=671288#post671288