Archive: problem in auto-uninstalling old application before installing new application


problem in auto-uninstalling old application before installing new application
Hi,

I am trying http://nsis.sourceforge.net/archive/...b.php?page=385

to Auto-uninstall old application before installing new application.

My Script looks like this
--------
Function .onInit
System::Call 'kernel32::CreateMutexA(i 0, i 0, t "1234") i .r1 ?e'
Pop $R0
StrCmp $R0 0 +3
MessageBox MB_OK "Installer is already running. Press OK to exit"
Abort

ReadRegStr $R0 HKLM \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" \
"UninstallString"
StrCmp $R0 "" done

MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
"${APPNAME} is already installed. $\n$\nClick `OK` to remove the \
previous version or `Cancel` to cancel this upgrade." \
IDOK uninst
Abort

uninst:
ClearErrors
ExecWait '$R0 _?=$INSTDIR' ;Do not copy the uninstaller to a temp file

IfErrors no_remove_uninstaller

Goto uninstaller
;components page, make sure all sections are uninstalled.

no_remove_uninstaller:

done:

FunctionEnd

Section Uninstall
uninstaller:

;Remove from registry...
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}"
DeleteRegKey HKLM "SOFTWARE\${APPNAME}"

; Delete self
Delete "$INSTDIR\uninstall.exe"

SectionEnd
--------------------
This script is not working because of some problem in uninstaller section.

I have written an uninstaller section seperately and i want control to jump to that section for uninstallation.

what is the problem there??


Hi :)

Well, I didn't go in details through the whole script but I think you've missed the point of the example:

i want control to jump to that section for uninstallation.
An installer don't jump to the Uninstall Section'. This special section is called automatically when the uninstaller is executed.

Therefore in the '.onInit' function of your application you just have to execute the uninstaller of the previous version, providing that the 'Uninstall Section' of the previous version contains the code required to remove it. Not the 'Uninstall Section' of this version.


evilO/Olive

Thanks for the reply.

Didn't thought in that direction :(

:) Done.