You can do something like:
; -- UninstallCodeExample1.iss --
;
; This script shows various things you can achieve using a [Code] section for Uninstall
[Setup]
AppName=My Program
AppVerName=My Program version 1.5
DefaultDirName={pf}\My Program
DefaultGroupName=My Program
UninstallDisplayIcon={app}\MyProg.exe
OutputDir=userdocs:Inno Setup Examples Output
[Files]
Source: "MyProg.exe"; DestDir: "{app}"
Source: "MyProg.chm"; DestDir: "{app}"
Source: "Readme.txt"; DestDir: "{app}"; Flags: isreadme
[Code]
function InitializeUninstall(): Boolean;
begin
Result := MsgBox('InitializeUninstall:' #13#13 'Uninstall is initializing. Do you really want to start Uninstall?', mbConfirmation, MB_YESNO) = idYes;
if Result = False then
MsgBox('InitializeUninstall:' #13#13 'Ok, bye bye.', mbInformation, MB_OK);
end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var
mRes : integer;
begin
case CurUninstallStep of
usUninstall:
begin
mRes := MsgBox('Do you want to remove all files?', mbConfirmation, MB_YESNO or MB_DEFBUTTON2)
if mRes = IDYES then
begin
MsgBox ('Really remove the files', mbInformation, MB_OK)
DeleteFile('path\filename.ext');
End
else
MsgBox ('Don''t remove the game files', mbInformation, MB_OK);
// ...insert code to perform pre-uninstall tasks here...
end;
end;
end;
You would want to use the latest version of InnoSetup as that's what I tested with. The sample above is based on the UninstallCodeExample.iss included with the InnoSetup compiler.
I added a line of code to show how to delete a file. It calls the DeleteFile function. You would need to add a DeleteFile for each file you want to remove at uninstall that isn't in your [Files] section.