Reputation: 205
I have a question about deleting folders during uninstallation using Inno Setup.
In my script, I use the uninsrestartdelete
flag on some files and call DelTree
on the {app}
folder on the last step of uninstallation. Sometimes, I can't delete all files until system restart (those are code injection DLLs). In this situation, I can't delete the {app}
folder successfully. What's the correct way to delete the {app}
folder on system restart as well? I can make sure there is no file left in the folder When I try to delete it.
Upvotes: 2
Views: 584
Reputation: 202682
To schedule file or directory deletion on restart, call RestartReplace
function with DestFile
(second) argument set to an empty string (''
).
RestartReplace(FileToDelete, '');
For directories, this works, only if they are empty. So you will have to first call RestartReplace
for all files inside the directory, which cannot be deleted.
For details, refer to WinAPI function MoveFileEx
and its MOVEFILE_DELAY_UNTIL_REBOOT
flag, which is behind the Inno Setup RestartReplace
function.
Upvotes: 1