Archive: run uninstaller if exec fails


run uninstaller if exec fails
Hi,

As part of my installation I call execwait to run a c# exe. If this fails the user is notified and I would like to run unnstall. I have tried calling ExecWait "$INSTDIR/uninst.exe", however this then asks the user if they want to cancel (needed for std uninstall), when I don't want to give the user a choice.

I would also like to do this if there is an error in the install generally. I clear errors at the start and can test if there are errors at the end, so I guess the calling of the uninstaller would be the same as the above?

Thanks.


1. It goes with the /S (silent) switch however ExecWait "$INSTDIR/uninst.exe" would not operate properly.
The method on how to call the uninstaller from the installer explained in the included example makensis.nsi, I'd suggest follow that method.

2. Normally would be the same, you have to try though.


Thanks for your comments. I have taken the example code you mentioned and now have the following code in the _Post section of my installer (this is where I run my .exe, as I need to know that the registry info has been set up...if there is a better place to have it then let me know):

I can't get the messageboxes to turn off by using the /S switch...I just create an error...how should I implement that?

Silent_Uninstall:
ReadRegStr $R1 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SmartChart" "UninstallString"

;Run uninstaller
HideWindow

ClearErrors
ExecWait '$R1 _?=$INSTDIR'

IfErrors no_remove_uninstaller
;IfFileExists "$INSTDIR\SmartChart.exe" no_remove_uninstaller
Delete $R1
RMDir $INSTDIR

no_remove_uninstaller:
Quit


done:
SectionEnd


You'd need the /SD switch for the message boxes, refer to NSIS documentation about.