Silent uninstall always exits with errorlevel
Hi,
I have the following problem.
Calling the uninstaller in silent mode from a batch file which checks the returned error level, always gives error level 2.
Adding SetErrorLevel 0 as last instruction in the uninstaller section DOES NOT help.
Second strange behaviour:
I placed 2 Messageboxes with debug output into the uninstaller section. Both MessageBoxes appear one after the other, but when the first one appears, the installer has already finished and returned to the calling batch file.
1. What happens after this section, that sets the errorlevel to 2
2. Why do the Messageboxes NOT interrupt the program and wait until OK is pressed?
Section Uninstall
SetDetailsPrint None
StrCmp $MustUpdate "1" SkipUninstDriver
Call un.InstallDriver
SkipUninstDriver:
; Can't uninstall if uninstall log is missing!
IfFileExists "$INSTDIR\${UninstLogfileName}" NormalUninst
# MessageBox MB_YESNO|MB_ICONSTOP "$(UninstLogMissing)$\r$\n$(ForcedUninst)" /SD IDNO IDYES ForcedUninst
# Abort
ForcedUninst:
StrCmp "$INSTDIR" "${DEFAULTDIR}" 0 NoUninstall
Delete "$INSTDIR\*.*"
Delete "${SYSDRIVERDIR}\$DriverBaseName${SYS_EXT}"
RmDir /r "$INSTDIR"
RmDir /r "$SMPROGRAMS\${OEM}\${PRODUCT}"
Push "RegOnly"
goto DoUninst
NoUninstall:
StrCpy $UserError "Unable to uninstall: $INSTDIR\${UninstLogfileName} missing and not installed in ${DEFAULTDIR}"
MessageBox MB_ICONEXCLAMATION|MB_OK "$UserError"
goto UnInstDone
NormalUninst:
SetDetailsPrint None
Push $R0
Push $R1
Push $R2
Push $R4
Push ""
DoUninst:
Call un.NormalUninst
UninstDone:
${Log} "[ResponseResult]"
StrCpy $R0 "0"
MessageBox MB_ICONINFORMATION|MB_OK "UserError=$UserError ($R0)"
StrCmp $UserError "" LogResult
StrCpy $R0 "2"
LogResult:
${Log} "ResultCode=$R0"
SetErrorLevel $R0
StrCmp $UserError "" +2
${Log} "ErrMessage=$UserError"
FileClose $InstLog
SetFileAttributes "$InstLogDir\$InstallLog" READONLY
Pop $R4
Pop $R2
Pop $R1
Pop $R0
StrCmp $UserError "" Done
Call un.closelog
Abort
Done:
MessageBox MB_ICONINFORMATION|MB_OK "Setting ErrorLevel to 0"
SetErrorLevel 0
SectionEnd