Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

files will not delete

Apr
1,794
15
I have several files that will not delete - in TCMD / TCC / windows 10 Explorer. Does anyone have a script where you pass it a file name and it says the attributes (R,H,S,A, etc) and who has the rights to access the file and what rights those are?
 
It should be easy enough to make one. You can get the attributes with TCC's @ATTRIB[] (and the owner with %OWNER[]). And you can get permissions with ICACLS.EXE (Windows built-in). In the output below, "I" means inherited, "F" means full, "M" means modify, and "RX" means read/execute. Do ICACLS /? for more info.

Code:
v:\> echo %@attrib[w32tmparams.btm]
___A_____________

v:\> echo %@owner[w32tmparams.btm]
JJ\vefatica

v:\> icacls w32tmparams.btm
w32tmparams.btm BUILTIN\Administrators:(I)(F)
                NT AUTHORITY\SYSTEM:(I)(F)
                NT AUTHORITY\Authenticated Users:(I)(M)
                BUILTIN\Users:(I)(RX)

Successfully processed 1 files; Failed processing 0 files
 
Anything else to check/display that might prevent a file from deleted?

Thank you @vefatica !!! Right there with a helpful reply!
 
Code:
[C:\Users\csgal\OneDrive\Desktop\JV16PT\thursday]set fn=%@line[thursday.txt,0]

[C:\Users\csgal\OneDrive\Desktop\JV16PT\thursday]echo %fn
C:\Backup\Windows\servicing\LCU\Package_for_RollupFix~31bf3856ad364e35~amd64~~19041.1415.1.6\amd64_microsoft-windows-a..g-whatsnew.appxmain_31bf3856ad364e35_10.0.19041.746_none_57c8601baf818c0d\f\new360videossquare44x44logo.targetsize-16_altform-unplated_contrast-black.png

[C:\Users\csgal\OneDrive\Desktop\JV16PT\thursday]echo %@attrib[%fn]
___A_____________

[C:\Users\csgal\OneDrive\Desktop\JV16PT\thursday]echo %@owner[%fn]
BUILTIN\Administrators

[C:\Users\csgal\OneDrive\Desktop\JV16PT\thursday]icacls "%fn"
C:\Backup\Windows\servicing\LCU\Package_for_RollupFix~31bf3856ad364e35~amd64~~19041.1415.1.6\amd64_microsoft-windows-a..g-whatsnew.appxmain_31bf3856ad364e35_10.0.19041.746_none_57c8601baf818c0d\f\new360videossquare44x44logo.targetsize-16_altform-unplated_contrast-black.png: The sy
stem cannot find the path specified.
Successfully processed 0 files; Failed processing 1 files

[C:\Users\csgal\OneDrive\Desktop\JV16PT\thursday]icacls %fn
C:\Backup\Windows\servicing\LCU\Package_for_RollupFix~31bf3856ad364e35~amd64~~19041.1415.1.6\amd64_microsoft-windows-a..g-whatsnew.appxmain_31bf3856ad364e35_10.0.19041.746_none_57c8601baf818c0d\f\new360videossquare44x44logo.targetsize-16_altform-unplated_contrast-black.png: The sy
stem cannot find the path specified.
Successfully processed 0 files; Failed processing 1 files

[C:\Users\csgal\OneDrive\Desktop\JV16PT\thursday]

Any thoughts?
 
@vefatica or anyone else:

Any idea what would cause

[C:\path\] icacls "%fn"

to say "The system cannot find the path specified.
Successfully processed 0 files; Failed processing 1 files

[C:\Users\csgal\OneDrive\Desktop\JV16PT\thursday]"
 
Not a clue! Are you csgal when you try that? Is OneDrive running? Maybe it locks files. If you have ProcessMonitor (sysinternals) you can monitor file system activity and get a better idea why it failed.
 
Not a clue! Are you csgal when you try that? Is OneDrive running? Maybe it locks files. If you have ProcessMonitor (sysinternals) you can monitor file system activity and get a better idea why it failed.

Yes - i am csgal - the only user on this box. not a LAN. I do use OneDrive.

 
ProcrssExplorer will tell you only that a file is open.. But it won't tell you the sharing options specified when the file was opened. ProcessMonitor (monitoring TCC) will tell you those options and why TCC failed to open it. Set it up like this.

1661303655088.png
 
The name "C:\Backup\Windows\servicing\LCU\Package_for_RollupFix~31bf3856ad364e35~amd64~~19041.1415.1.6\amd64_microsoft-windows-a..g-whatsnew.appxmain_31bf3856ad364e35_10.0.19041.746_none_57c8601baf818c0d\f\new360videossquare44x44logo.targetsize-16_altform-unplated_contrast-black.png" is 273 chars long. Maybe it is too long?
regards
Rodolfo Giovanninetti
 
I tried Your same commands and I got the same error.
Then I used the subst command "subst p: C:\Backup\Windows\servicing\LCU\Package_for_RollupFix~31bf3856ad364e35~amd64~~19041.1415.1.6\amd64_microsoft-windows-a..g-whatsnew.appxmain_31bf3856ad364e35_10.0.19041.746_none_57c8601baf818c0d\f".
And then the command "icacls P:\new360videossquare44x44logo.targetsize-16_altform-unplated_contrast-black.png" worked.
So yes it seems that the path/filename is too long.
With subst You should be able to erase the file or at least check permissions.
regards
Rodolfo Giovanninetti
 
How about a BTM that would be of the form:

Code:
for %fn in (@thursday.txt) (
  : list name - currently in %fn
  : list attributes of %fn
  : list owner of %fn
  : subst p: %@path[%fn]
  : run the icacls p:%@filename[%fn]
  : SUBST p: /D
)
 
How about a BTM that would be of the form:

Code:
for %fn in (@thursday.txt) (
  : list name - currently in %fn
  : list attributes of %fn
  : list owner of %fn
  : subst p: %@path[%fn]
  : run the icacls p:%@filename[%fn]
  : SUBST p: /D
)
Or you could CDD %@path[%fn] and icacls %@filename[%fn]
 
Back
Top