I struggled with this issues A LOT.
First of all DO NOT USE
icacls "C:\Program Files\WindowsApps" /reset /t /c /q.
It will remove special conditional permissions from folder and give it windows default and inherited ACLs which is should not be done to WindowsApps.
Here is answer I found that worked for me (Win10 and Win11 21H2) and didn't cause any troubles (at least troubles i know about)
Firstly open the Command Prompt with Administrative Privileges
Ensure that you have ownership of WindowsApps folder by running next command
takeown /f "%ProgramFiles%\WindowsApps"
- Restore innitial permissions to that folder by running this
cacls "%programfiles%\WindowsApps" /s:"D:PAI(A;;FA;;;S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464)(A;OICIIO;GA;;;S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464)(A;;0x1200a9;;;S-1-15-3-1024-3635283841-2530182609-996808640-1887759898-3848208603-3313616867-983405619-2501854204)(A;OICIIO;GXGR;;;S-1-15-3-1024-3635283841-2530182609-996808640-1887759898-3848208603-3313616867-983405619-2501854204)(A;;FA;;;SY)(A;OICIIO;GA;;;SY)(A;CI;0x1200a9;;;BA)(A;OICI;0x1200a9;;;LS)(A;OICI;0x1200a9;;;NS)(A;OICI;0x1200a9;;;RC)(XA;;0x1200a9;;;BU;(Exists WIN://SYSAPPID))"
OR if cacls is not accesible, use icacls. To do so create temp.txt file with next content and save it somewhere, for example to c:\
windowsapps
D:PAI(A;;FA;;;S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464)(A;OICIIO;GA;;;S-1-5-80-956008885-3418522649-1831038044-1853292631-2271478464)(A;;0x1200a9;;;S-1-15-3-1024-3635283841-2530182609-996808640-1887759898-3848208603-3313616867-983405619-2501854204)(A;OICIIO;GXGR;;;S-1-15-3-1024-3635283841-2530182609-996808640-1887759898-3848208603-3313616867-983405619-2501854204)(A;;FA;;;SY)(A;OICIIO;GA;;;SY)(A;CI;0x1200a9;;;BA)(A;OICI;0x1200a9;;;LS)(A;OICI;0x1200a9;;;NS)(A;OICI;0x1200a9;;;RC)(XA;;0x1200a9;;;BU;(Exists WIN://SYSAPPID))
and then run
icacls "%programfiles%" /restore c:\temp.txt
- give ownership of WindowsApps back to trustedinstaller
icacls "%programfiles%\WindowsApps" /setowner "nt service\trustedinstaller"
if it doesn't work from cmd - right click on WindowsApps folder in explorer, open properties and go to security tab, click Advanced and click Change button against Owner. There enter NT Service\TrustedInstaller (with space between NT and Service and without quotes) and click Check Names button. Click OK and finnaly apply changes.
After this manipulations permissions on WindowsApps folder should be restored to default and all UWP apps should work fine (wt.exe for example)
P.S.
Default ACLs for WindowsApps is
NT SERVICE\TrustedInstaller:(F)
NT SERVICE\TrustedInstaller:(OI)(CI)(IO)(F)
S-1-15-3-1024-3635283841-2530182609-996808640-1887759898-3848208603-3313616867-983405619-2501854204:(RX)
S-1-15-3-1024-3635283841-2530182609-996808640-1887759898-3848208603-3313616867-983405619-2501854204:(OI)(CI)(IO)(GR,GE)
NT AUTHORITY\SYSTEM:(F)
NT AUTHORITY\SYSTEM:(OI)(CI)(IO)(F)
BUILTIN\Administrators:(CI)(RX)
NT AUTHORITY\LOCAL SERVICE:(OI)(CI)(RX)
NT AUTHORITY\NETWORK SERVICE:(OI)(CI)(RX)
NT AUTHORITY\RESTRICTED:(OI)(CI)(RX)
BUILTIN\Users:(Rc,S,RD,REA,X,RA)
and commands above is meant to set it so.
Most usefull info I took from winhelponline blog, so credit to it.
I chose to write big answer and not to just give a link because I think it's better to keep useful info at many places and not just at one blog.