1

I have three calls in a row for DelTree() in CurUninstallStepChanged() for usPostUninstall like this:

if IsDeleteAData then
begin
  Res:=DelTree(AppData+'\ADirName', true, true, true);
  Log('Delete '+AppData+'\ADirName result: '+IntToStr(Integer(Res)));
end;

if IsDeleteBData then
begin
  Res:=DelTree(AppData+'\BDirName', true, true, true);
  Log('Delete '+AppData+'\BDirName result: '+IntToStr(Integer(Res)));
end;

if IsDeleteCData then
begin
  Res:=DelTree(AppData+'\CDirName', true, true, true);
  Log('Delete '+AppData+'\CDirName result: '+IntToStr(Integer(Res)));
end;

A and B delete everything like it should. However, C will not delete the top level dir (the actual CDirName) but does delete the contents, if the CDirName is empty it will remove the CDirName directory itself.

If I enable logging all I get is that the result was 0 when it doesn't delete the top level directory.

It did this in 6.0.3 and now updated today to 6.2.0 and still doing it. Any ideas or way to dig in deeper? I've never had a problem with DelTree() in the past.

I captured the process information and it basically just says CANNOT DELETE:

"Time of Day","Process Name","PID","Operation","Path","Result","Detail"
"7:35:00.0095154 PM","_iu14D2N.tmp","1616","CreateFile","C:\Users\testing\AppData\Roaming\CDirName","SUCCESS","Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened"
"7:35:00.0095290 PM","_iu14D2N.tmp","1616","QueryBasicInformationFile","C:\Users\testing\AppData\Roaming\CDirName","SUCCESS","CreationTime: 10/6/2021 7:20:47 PM, LastAccessTime: 10/6/2021 7:30:50 PM, LastWriteTime: 10/6/2021 7:28:54 PM, ChangeTime: 10/6/2021 7:28:54 PM, FileAttributes: RD"
"7:35:00.0095347 PM","_iu14D2N.tmp","1616","CloseFile","C:\Users\testing\AppData\Roaming\CDirName","SUCCESS",""
"7:35:00.0095902 PM","_iu14D2N.tmp","1616","CreateFile","C:\Users\testing\AppData\Roaming\CDirName","SUCCESS","Desired Access: Read Data/List Directory, Synchronize, Disposition: Open, Options: Directory, Synchronous IO Non-Alert, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened"
"7:35:00.0096079 PM","_iu14D2N.tmp","1616","QueryDirectory","C:\Users\testing\AppData\Roaming\CDirName\*","SUCCESS","Filter: *, 1: ."
"7:35:00.0096363 PM","_iu14D2N.tmp","1616","QueryDirectory","C:\Users\testing\AppData\Roaming\CDirName","SUCCESS","0: .., 1: desktop.ini, 2: Paint.lnk"
"7:35:00.0096876 PM","_iu14D2N.tmp","1616","CreateFile","C:\Users\testing\AppData\Roaming\CDirName\desktop.ini","SUCCESS","Desired Access: Read Attributes, Delete, Disposition: Open, Options: Non-Directory File, Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened"
"7:35:00.0097112 PM","_iu14D2N.tmp","1616","QueryAttributeTagFile","C:\Users\testing\AppData\Roaming\CDirName\desktop.ini","SUCCESS","Attributes: HS, ReparseTag: 0x0"
"7:35:00.0097230 PM","_iu14D2N.tmp","1616","<Unknown>","C:\Users\testing\AppData\Roaming\CDirName\desktop.ini","SUCCESS",""
"7:35:00.0097332 PM","_iu14D2N.tmp","1616","CloseFile","C:\Users\testing\AppData\Roaming\CDirName\desktop.ini","SUCCESS",""
"7:35:00.0098645 PM","_iu14D2N.tmp","1616","CreateFile","C:\Users\testing\AppData\Roaming\CDirName\Paint.lnk","SUCCESS","Desired Access: Read Attributes, Delete, Disposition: Open, Options: Non-Directory File, Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened"
"7:35:00.0098873 PM","_iu14D2N.tmp","1616","QueryAttributeTagFile","C:\Users\testing\AppData\Roaming\CDirName\Paint.lnk","SUCCESS","Attributes: A, ReparseTag: 0x0"
"7:35:00.0098956 PM","_iu14D2N.tmp","1616","<Unknown>","C:\Users\testing\AppData\Roaming\CDirName\Paint.lnk","SUCCESS",""
"7:35:00.0099040 PM","_iu14D2N.tmp","1616","CloseFile","C:\Users\testing\AppData\Roaming\CDirName\Paint.lnk","SUCCESS",""
"7:35:00.0099720 PM","_iu14D2N.tmp","1616","QueryDirectory","C:\Users\testing\AppData\Roaming\CDirName","NO MORE FILES",""
"7:35:00.0099817 PM","_iu14D2N.tmp","1616","CloseFile","C:\Users\testing\AppData\Roaming\CDirName","SUCCESS",""
"7:35:00.0100469 PM","_iu14D2N.tmp","1616","CreateFile","C:\Users\testing\AppData\Roaming\CDirName","SUCCESS","Desired Access: Read Attributes, Delete, Synchronize, Disposition: Open, Options: Directory, Synchronous IO Non-Alert, Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened"
"7:35:00.0100652 PM","_iu14D2N.tmp","1616","QueryAttributeTagFile","C:\Users\testing\AppData\Roaming\CDirName","SUCCESS","Attributes: RD, ReparseTag: 0x0"
"7:35:00.0100727 PM","_iu14D2N.tmp","1616","<Unknown>","C:\Users\testing\AppData\Roaming\CDirName","CANNOT DELETE",""
"7:35:00.0100840 PM","_iu14D2N.tmp","1616","CloseFile","C:\Users\testing\AppData\Roaming\CDirName","SUCCESS",""

Then I tried adding another RemoveDir on usDone and that still gave:

"7:35:01.7108218 PM","_iu14D2N.tmp","1616","CreateFile","C:\Users\testing\AppData\Roaming\CDirName","SUCCESS","Desired Access: Read Attributes, Delete, Synchronize, Disposition: Open, Options: Directory, Synchronous IO Non-Alert, Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened"
"7:35:01.7108617 PM","_iu14D2N.tmp","1616","QueryAttributeTagFile","C:\Users\testing\AppData\Roaming\CDirName","SUCCESS","Attributes: RD, ReparseTag: 0x0"
"7:35:01.7108724 PM","_iu14D2N.tmp","1616","<Unknown>","C:\Users\testing\AppData\Roaming\CDirName","CANNOT DELETE",""
"7:35:01.7108875 PM","_iu14D2N.tmp","1616","CloseFile","C:\Users\testing\AppData\Roaming\CDirName","SUCCESS",""
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
user3161924
  • 1,849
  • 18
  • 33
  • Are there any user-created files in that folder? Uninstallers will not remove anything they did not create, because it could risk loss of user data. For instance, a user could save an important file in that folder by mistake, and if the uninstaller removed it the harm couldn't be undone. It also could mean that the user was uninstalling with the intent to reinstall, and any user settings should be preserved. – Ken White Oct 07 '21 at 03:04
  • This is from the [code] section using pascal scripting language. I've check the current directory and that was C:\Windows\System32 so that wasn't it. I'm thinking something has an open handle on it some place. Hm, maybe I should check that with process explorer. – user3161924 Oct 07 '21 at 03:27
  • - nope no in use handles on it – user3161924 Oct 07 '21 at 03:32
  • I didn't ask about in-use handles. I asked about any files the user may have saved in that folder. They don't have to be in use - they just have to exist. – Ken White Oct 07 '21 at 03:36
  • I found the reason why after coming across a similar question when desktop.ini is created it sets the folder its in to read-only (so folders can get attributes like files). So I need to remove that for deltree to finish that off. But I don't see an option to set attributes in the inno setup pascal function set. Is that available or have to write interface to SetFileAttributes winapi? – user3161924 Oct 07 '21 at 18:26

0 Answers0