Skip to content

Instantly share code, notes, and snippets.

@jakoch
Created March 20, 2016 23:39
Show Gist options
  • Save jakoch/f9340f85a029b3adf253 to your computer and use it in GitHub Desktop.
Save jakoch/f9340f85a029b3adf253 to your computer and use it in GitHub Desktop.
InnoSetup Uninstall by deleting the application folder
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
// warn the user, that his working folder is going to be deleted and projects might get lost
if (CurUninstallStep = usUninstall) then begin
if MsgBox('***WARNING***'#13#10#13#10 +
'The installation folder is [ '+ ExpandConstant('{app}') +' ].'#13#10 +
'You are about to delete this folder and all its subfolders,'#13#10 +
'including [ '+ ExpandConstant('{app}') +'\important_projects_folder ], which may contain your projects.'#13#10#13#10 +
'This is your last chance to do a backup of your files.'#13#10#13#10 +
'Do you want to proceed?'#13#10, mbConfirmation, MB_YESNO) = IDYES
then begin
// User clicked: YES
// fix "read-only" status of all files and folders, else some things might remain after uninstallation
ExecHidden('cmd.exe /c "attrib -R ' + appDir + '\*.* /s /d"');
// Deletes the application directory and everything inside it.
// This function will remove directories that are reparse points,
// but it will not recursively delete files/directories inside them.
DelTree(ExpandConstant('{app}'), True, True, True);
end else begin
// User clicked: No
Abort;
end;
end;
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment