How to replace permissions with Setacl

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Docfxit
Posts: 130
Joined: 12 Nov 2015 12:42

How to replace permissions with Setacl

#1 Post by Docfxit » 22 Feb 2023 11:25

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 2286 times
I need to change the permissions so i can delete the file. I'm running in Windows 10. My user has administrator rights.

Compo
Posts: 599
Joined: 21 Mar 2014 08:50

Re: How to replace permissions with Setacl

#2 Post by Compo » 22 Feb 2023 11:48

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.

Docfxit
Posts: 130
Joined: 12 Nov 2015 12:42

Re: How to replace permissions with Setacl

#3 Post by Docfxit » 22 Feb 2023 12:10

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?

Docfxit
Posts: 130
Joined: 12 Nov 2015 12:42

Re: How to replace permissions with Setacl

#4 Post by Docfxit » 23 Feb 2023 22:38

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"

Post Reply