Archive: WriteUninstaller doesn't ever return error


WriteUninstaller doesn't ever return error
Hi all,

I noticed that the WriteUninstaller is always returning success even if it fails.

Let's consider the following code uninstaller-generator.nsi (everything we have in the installer part is to just generate the uninstaller):


Section -Post
WriteUninstaller "$EXEDIR\uninst.exe"
SectionEnd


Samples of failures:
a) When running the exe generated when building the uninstaller-generator.nsi above, if I already have an uninst.exe in the $EXEDIR which is read-only, the WriteUninstaller fails, but still it returns success

b) If I change the code to:

Section -Post
WriteUninstaller "K:\uninst.exe"
SectionEnd

and K: doesn't exist on my system the WriteUninstaller fails, but actually again it returns success.

Is this is a bug? I mean for this kind of installer, I'll never be able to check if there was an error when running it right?

Thx,
Viv

How exactly does it return success? The following piece of code works fine for me.

WriteUninstaller $TEMP\uninst.exe
SetFileAttributes $TEMP\uninst.exe READONLY
ClearErrors
WriteUninstaller $TEMP\uninst.exe
${If} ${Errors}
DetailPrint "errors"
${Else}
DetailPrint "no errors"
${EndIf}

Hi kichik,

I actually got confused between error codes and error levels. I thought that that if any instruction fails, then the error code returned by default is different than 0. Seems it's not the case. Seems that you need to check it yoursef with IfErrors and in case use SetErrorLevel so that it will return a value different than 0.

Thx,
Viv