uninstallation errors
Hi,
in my installer, during .onInit I call UninstallPreviousSoftware, code below. I think that there are two problems with this code and would appreciate advice.
1. If my product has already been installed then I call its uninstaller using ExecWait, before continuing with the new installer. When the old uninstaller is running, if I cancel out of it, I was expecting it to return an error code that I could pick up as such. However I do not seem to get any error returned and so the following code will then delete the old uninstaller.
2. I am not totally sure that the HideWindow and BringToFront code is working, I have seen times when after the uninstaller has finished, the installer is still running in the task manager but it seems to be hidden.
Function UninstallPreviousSoftware
#if a previous version of the software is already installed, then uninstall it. When uninstalling:
#- if the new software is an updater installer, then tell the uninstaller, using a command line parameter,
# that a subsequent reinstall will take place, so that it *should not delete everything*
#- if the new software is a full installer, then tell the uninstaller that a subsequent reinstall
# will take place, so that it *should delete everything*
Push $R0
Push $R1
Push $R2
ReadRegStr $R0 "HKEY_LOCAL_MACHINE" "${MY_ADD_REMOVE_PROGRAMS_REGISTRY_KEY}" "UninstallString"
${If} "" != $R0
IfFileExists $R0 0 done
HideWindow
ClearErrors
StrCpy $R1 ""
!ifdef UPDATER_BUILD
StrCpy $R1${MY_UPDATER_UNINSTALL_COMMAND_LINE_PARAMETER}
!endif
ExecWait "$R0 $R1 _?=$INSTDIR" $R2
${If} ${Errors}
MessageBox MB_OK "uninstall error = $R2"
ClearErrors
${Else}
Delete "$R0"
RMDir "$INSTDIR"
${EndIf}
BringToFront
${EndIf}
done:
Pop $R2
Pop $R1
Pop $R0
FunctionEnd
>