Archive: auto-uninstall when installation failed


auto-uninstall when installation failed
Hi,
If an installer aborts in the middle of the installation, is there any way to call uninstaller to clean up files that were installed up to when the installer aborts.

Thanks!


Hi,
you may use the functions .onInstFailed and .onUserAbort to simulate a rollback, removing all changes made by your installer. :-)


Hi,
I copied the code that's in un.onInit function to .onInstFailed function. But it didn't successfully removed the installed files.

Function un.onInit
ReadRegStr $INSTDIR HKLM "${REGKEY}" Path
ReadRegStr $StartMenuGroup HKLM "${REGKEY}" StartMenuGroup
!insertmacro SELECT_UNSECTION Component1 ${UNSEC0000}
FunctionEnd

Function .onInstFailed
ReadRegStr $INSTDIR HKLM "${REGKEY}" Path
ReadRegStr $StartMenuGroup HKLM "${REGKEY}" StartMenuGroup
!insertmacro SELECT_UNSECTION Component1 ${UNSEC0000}
MessageBox MB_OK "Installation of $(^Name) Failed"
FunctionEnd


how do I debug this problem?

Thanks!


this is not enough, you have to call a custom function and perform actions e.g. when .onInstFailed and/or .onUserAbort is true, then remove these files from that dir, remove those entries from registry, stop that service etc. You could write a specific uninstaller for this case, extract it only when the case is true, and simulate the "perform rollback" action like other applications do. :-)


thanks! got it. :)