Windows – Editing/Creating files in C:\Program Files\WindowsApps

permissionswindowswindows-10-preview

Lately, I've been quite annoyed at the fact that I can't edit files in C:\Program Files\WindowsApps folder. I've used the takedown command, in elevated CMD, and changed permissions, to allow admins to have full control (I am an admin), and changed owner to Administrators. I can delete files/folders, yet, whenever I try to edit files, or add files, I get the error message "Access is denied." How do I enable creating files and editing files in WindowsApps?

Best Answer

The WindowsApps folder is one of the most heavily protected folders in Windows 10. It contains all the Windows UWP apps, to which Microsoft zealously guards the access. The protections on this folder may change across Windows versions.

The usual methods of taking ownership and assigning permissions are not enough for this folder, but are still required as first step to gaining access. After executing them, accessing the folder is now possible for copying, but editing is still blocked. To edit, one needs to save the file elsewhere, and only then replace the original with the edited version.

A further note is that restoring the ownership of the folder to TrustedInstaller is possible without losing the extra permissions that were assigned, by using the command:

icacls "%ProgramFiles%\WindowsApps" /setowner "NT Service\TrustedInstaller" /t

If someone wishes to use an elevated Command Prompt for gaining access to the folder, then these are the commands :

    takeown /F "%ProgramFiles%\WindowsApps"
    takeown /F "%ProgramFiles%\WindowsApps" /r /d y
    icacls "%ProgramFiles%\WindowsApps" /grant Administrators:F
    icacls "%ProgramFiles%\WindowsApps" /grant Administrators:F /t

I also note that permission problems can be avoided by using the following commands before and after changing permissions to completely restore the original permissions :

icacls "%ProgramFiles%\WindowsApps" /save WindowsApps.acl
icacls "%ProgramFiles%" /restore WindowsApps.acl

To complement the poster's remark about restoring the original permissions on the folder while not having saved these permissions before starting, this is done by entering in an elevated Command Prompt (cmd) the command :

icacls "%ProgramFiles%\WindowsApps" /q /c /t /reset

If the command does not work, it needs to be redone from a Windows boot CD/USB, as explained in the post Reset default ACLs for C:\Program Files\WindowsApps:

  1. Follow the instructions on this page to create the Windows Installation Media
  2. Boot from the USB/CD, click "Repair my computer" upon reaching the Install button
  3. Select Troubleshoot, then Command Prompt
  4. Your current drive C: will be the boot media, with your Windows system disk likely in D:, so verify using dir D:, and if not, then search for the right drive-letter
  5. Using the drive letter you just found (maybe D:\), issue the command:

    icacls "D:\Program Files\WindowsApps" /q /c /t /reset
    
  6. Wait for the operation to complete, and check the output for errors

  7. Reboot.
Related Question