I have this code in the [Code]
section, this code only runs when I run the uninstaller:
//////////////
// Uninstaller
//////////////
const
DeleteFiles = true;
DeleteSubdirs = false;
// Initialize the Inno Setup Uninstaller skin style.
function InitializeUninstall: Boolean;
begin
Result := True;
LoadVCLStyle_UnInstall(ExpandConstant('{app}\uninstall.vsf'));
end;
// Deinitialize the Inno Setup Uninstaller skin style.
procedure DeinitializeUninstall();
begin
UnLoadVCLStyles_UnInstall;
UnloadDll(ExpandConstant('{app}\uninstall.dll'));
DeleteFile(ExpandConstant('{app}\uninstall.dll'));
DelTree(ExpandConstant('{app}\'), true, DeleteFiles, DeleteSubdirs);
end;
The problem is that the instructions inside the DeinitializeUninstall
procedure of DeleteFile
and DelTree
runs even if the user choose Yes or No when the InnoSetup uninstaller asks the user whether really want to uninstall or not the software, I mean the user selection of this image:
Of course I understand what that procedure means and why my instructions runs even choosing No because the uninstaller is deinitialized whatever I choose, but just I can't find the right way to do this efficiently.
So I need to processs these two instructions below only if the user really demanded a uninstall choosing Yes, but also these instructions should run at the end of the uninstallation process (and that is the DeinitializeUninstall
procedure I supose):
DeleteFile(ExpandConstant('{app}\uninstall.dll'));
DelTree(ExpandConstant('{app}\'), true, DeleteFiles, DeleteSubdirs);
How I can do it?
The solution, thanks to @TLama for the
CurUninstallStepChanged
hint and thanks to this other answer where I've taken an example to realize this: