Page 1 of 1

How to replace permissions with Setacl

Posted: 22 Feb 2023 11:25
by Docfxit
I currently have:
(SET _KEY=C:\Windows\SystemApps)
%~d0\Batch\SetACL.exe -on "%_KEY%" -ot file -actn ace -ace "n:%username%;p:full
%~d0\Batch\SetACL.exe -on "%_KEY%" -ot file -actn ace -actn -clr "n:SYSTEM;p:full
%~d0\Batch\SetACL.exe -on "%_KEY%" -ot file -actn ace -ace "n:SYSTEM;p:full

It does nothing for this file:
C:\Windows\SystemApps\Microsoft.Windows.CloudExperienceHost_cw5n1h2txyewy\core\js\appLaunchers\WindowsCoreLocalAccountCreator.js

This is the current permissions:
Permissions.jpg
Permissions.jpg (145.43 KiB) Viewed 5030 times
I need to change the permissions so i can delete the file. I'm running in Windows 10. My user has administrator rights.

Re: How to replace permissions with Setacl

Posted: 22 Feb 2023 11:48
by Compo
If, as seen in your GUI screenshot, the only user who has the necessary permissions to modify, (nevermind delete), this, is the current owner, TrustedInstaller. For that reason, my assumption is that only TrustedInstaller can modify the permissions, you can clearly see that SYSTEM and Administrators, and Users cannot, (they can only read and execute).

Please review the methodology here.

Re: How to replace permissions with Setacl

Posted: 22 Feb 2023 12:10
by Docfxit
Thank you for the manual instructions.
I have a couple hundred files like this that I need to delete for Corel Wordperfect. I'd like to figure out how to do it in a bat file. I'm currently having trouble installing the latest version of Wordperfect. If I have this in a bat file, I can remove all the old versions on all the computers and clean it up to put the new version on.
Can you suggest how to replace the owner with SetACL.exe?

Re: How to replace permissions with Setacl

Posted: 23 Feb 2023 22:38
by Docfxit
I figured out how to do it. This allows me to delete the file.

Code: Select all

Set "Key=C:\Windows\SystemApps\Microsoft.Windows.CloudExperienceHost_cw5n1h2txyewy\core\js\appLaunchers\WindowsCoreLocalAccountCreator.js"
%~d0\Batch\setacl -on "%Key%" -ot file -actn setowner -ownr "n:%username%"
%~d0\Batch\SetACL -on "%Key%" -ot file -actn trustee -trst n1:System;ta:remtrst;w:dacl
%~d0\Batch\SetACL -on "%Key%" -ot file -actn trustee -trst n1:"ALL APPLICATION PACKAGES";ta:remtrst;w:dacl
%~d0\Batch\SetACL -on "%Key%" -ot file -actn trustee -trst n1:"ALL RESTRICTED APPLICATION PACKAGES";ta:remtrst;w:dacl
%~d0\Batch\SetACL -on "%Key%" -ot file -actn trustee -trst n1:Administrators;ta:remtrst;w:dacl
%~d0\Batch\SetACL -on "%Key%" -ot file -actn trustee -trst n1:Users;ta:remtrst;w:dacl
%~d0\Batch\SetACL -on "%KEY%" -ot file -actn ace -ace "n:%username%;p:full"