My version applies the options /F /A when deleting files, so has a better chance of removing write protected files.
The big benefit is that any file or key, and any inaccessible path that may harbour files, will be reported as FROZEN if it cannot be cleaned, and that identifies the files and keys the user needs to take ownership over so they can be manually purged.
When Push comes to Shove, I would be prepared to manually take down SFI.DAT with CACLS,
but I would fear horrendous consequences if my script were to include such an action.
I have not yet had any SFI.DAT aggravation, but if it will not go quietly that suggests to me that Comodo is still actively protecting its files, and perhaps my script will then get quarantined as malware ! ! !
Below is the output showing how my code presents the results when the target list is just a few items to which for test purposes I have caused various access problems.
N.B. the test script makes two attempts at removing folder "COMODO_TEST_0" and file "comodo_test.txt". They are both declared frozen because my debug test starts a CMD.EXE instance with current directory at COMODO_TEST_0 so Windows will not allow its removal, and it spends a few seconds doing PING redirected into "comodo_test.txt" so that file is also protected. The main script delays a bit longer until PING is done and the new instance of CMD.EXE closes, after which these two items are no longer frozen and can be killed.
Incidentally, "HKEY_LOCAL_MACHINE\SOFTWARE\ComodoGroup\Alan\Test2" is frozen because I added a sub-key and took ownership and write protected it against everyone.
I have thought of and tested against everything evil I can think of,
but experience has taught me that Windows has always got more evil gotchas up its sleeves !
Regards
Alan
---- KILL Comodo Files and REG_Keys ; 21:42:18.65 ----
KILL ? Y(es) / N(o) :- Y
Access is denied.
Needs Manual Intervention, Code 5 - Permissions Issues ?
FROZEN "C:\Documents and Settings\suzanne\"
ABSENT "C:\Documents and Settings\suza\"
VALID "C:\DOCUME~1\Dad\LOCALS~1\Temp\ZAP_CFP"
SEEKING FILES ...
The process cannot access the file because it is being used by another process.
++ FROZEN "COMODO_TEST_0" [RD /S /Q]
C:\DOCUME~1\Dad\LOCALS~1\Temp\ZAP_CFP\comodo_test.txt
The process cannot access the file because it is being used by another process.
++ FROZEN "comodo_test.txt" [DEL /F /A]
ABSENT "comodo_test.lst" [DEL /F /A]
KILLED "comodo_test.txt" [DEL /F /A]
KILLED "COMODO_TEST_0" [RD /S /Q]
SEEKING REGISTRY KEYS
Error: Access is denied.
++ FROZEN:- "HKEY_LOCAL_MACHINE\SOFTWARE\ComodoGroup\Alan"
Error: Access is denied.
++ FROZEN:- "HKEY_LOCAL_MACHINE\SOFTWARE\ComodoGroup\Alan\Test2"
KILLED:- "HKEY_LOCAL_MACHINE\SOFTWARE\ComodoGroup\Alan\Test3"
PATHS :- VALID = 1; FROZEN = 1; ABSENT = 1
FILES :- FOUND = 0; FROZEN = 2; KILLED = 2; ABSENT = 1
REG_Keys :- FOUND = 0; FROZEN = 2; KILLED = 1; ABSENT = 1
NEED FIX :- FOUND = 0; FROZEN = 5; KILLED = 3;
---- SHOW Comodo Files and REG_Keys ; 21:43:32.20 ----
SHOW ? Y(es) / N(o) :- Y