20

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?

8 Answers8

22

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.
harrymc
  • 455,459
  • 31
  • 526
  • 924
  • Interesting, in my case "The usual methods of taking ownership" already gives me the right to change and create files/folders (Windows 10 Pro). In what specific case isn't it enough? – Albin Oct 09 '18 at 09:25
  • 1
    @Albin: It's not enough since Windows has built-in protections specially for this folder that can only be worked around, not removed. – harrymc Oct 09 '18 at 09:40
  • @Albin Maybe you are not using Windows 1803 or 1809, because these version don't allow any file edits even when you have taken complete control, I will test these steps asap. – Gizmo Oct 09 '18 at 10:13
  • @harrymc I just checked, I'm using version 1803 on my testsystem. I also double checked, I tried to edit and save an (exiting, not created by me) xlm file. It works without problems. – Albin Oct 09 '18 at 10:21
  • @Albin: I don't know the settings on your computer and I cannot diagnose, Microsoft does not furnish any information about this. – harrymc Oct 09 '18 at 10:25
  • @harrymc There are no "additional" settings. It's a updated but otherwise untouched Win10pro System, I just changed the ownership. Also after reapplying the ownership, the user keeps the access using the IU-methode, you don't necessarily have to use the command line method to keep you're access. – Albin Oct 09 '18 at 10:35
  • @Albin: Everything is possible where Microsoft is concerned. – harrymc Oct 09 '18 at 10:37
  • :'D anyway let me know the results of you're test – Albin Oct 09 '18 at 10:39
  • 1
    So I tested by just using `icacls /save` then `icacls reset` then `icacls /restore` but that made the apps unusable too. Something is getting broken / not restored. I'm stuck in figuring out how to make the apps work again after gaining access to the folder, even without modification. I do have developer mode enabled so I should be somehow able to launch the apps outside of WindowsApps folder, I just don't know how.. but developers should be able to test their apps, right..? I ran all commands from a "Trusted Installer" CommandPrompt (RunAsTi64) because running it from admin wouldn't work. – Gizmo Oct 09 '18 at 22:01
  • Doing it from a boot CD/USB might work better. – harrymc Oct 10 '18 at 07:31
  • I didn't want the bounty to go to waste and as this is the most comprehensive answer I gave it here. – Gizmo Oct 15 '18 at 12:08
  • @Gizmo: Did you solve the problem? – harrymc Oct 15 '18 at 12:10
  • no, It seems microsoft encrypts the files on the disk using a key, that is only aquired when launching the app from the ms-store. I don't know how to copy this key. Obviously there is no documentation for that. – Gizmo Oct 15 '18 at 12:52
  • @Gizmo: Obviously. – harrymc Oct 15 '18 at 13:05
  • I'm on Windows 1909 and these steps apparently no longer work for allowing edit access to the files under WindowsApps. I can see and read them, but not edit or create. – Nathan Reed Dec 21 '19 at 01:28
  • (And nor can I copy or move files into WindowsApps.) – Nathan Reed Dec 21 '19 at 02:09
  • @SaudAljaffer, I voted to reject your edit because ir should be an answer, and the script should be part of it instead of being a link. – Rohit Gupta Apr 01 '23 at 22:32
3

Level of difficulty [extremely advanced].

On Win 10 (almost latest version), I read Harry’s original post and chose to start with the backup:

  1. Click Start

  2. Type “cmd” and wait, don’t hit enter yet.

  3. Click “run as administrator”

  4. Type:

     cd \Progra~1 and hit enter
    
  5. Backup permissions:

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

I then continued with Harry’s guidance:

[Still]...an elevated Command Prompt for gaining access to the folder (but for grant I started with just my App, which had special settings it wanted me to update for EyeTV 64-bit):

takeown /F "%ProgramFiles%\WindowsApps"
takeown /F "%ProgramFiles%\WindowsApps" /r /d y
icacls "%ProgramFiles%\WindowsApps\GENIA...<-your App name" /grant Administrators:F
icacls "%ProgramFiles%\WindowsApps\GENIA...<-your App name" /grant Administrators:F /t

I was conservative I changed view settings: Select View > Options > Change folder and search options. Select the View tab and, in Advanced settings, select Show hidden files, folders, and drives and OK.

I then followed Albin’s post above to get more control and remove inheritance (not completely, but make it individual) on WindowsApps:

![Albin’s post images]

I now right click WindowsApps folder in C:\Program Files and unhide and uncheck read only.
Also gave myself, Admin, Full Control see Albin for permissions, and Apply

Then at elevated cmd:

icacls "file" /setowner "NT Service\\TrustedInstaller" /T /C

I went to my Genia folder in WindowsApps and copied the file I wanted to desktop, edited it and copied it back to just the Program Files folder (with Administrator confirmation).

Back in elevated command prompt I deleted the old file I wanted to change: del “filename.ini”.
Then I got Linus Torvalds Git app for windows, from wikipedia I Installed git-bash, then ran that “right-click” as administrator.
Copied the file using that and got a 0 byte empty file and error, but it did not break my apps, and proved write capability.

I got Ubuntu 12 and used Rufus in Freedos/mbr mode to make a bootable USB from Ubuntu AMD 64 or 32 iso, and BIOS boot to my UEFI USB.
In test mode I used The folder icon > Win10 “whatever your disk is called” to mount my drive.
In logo icon (top left), search terminal, click and navigate via:

cd /media/Win10/Program\ Files > enter
cat filename.ini > WindowsApps/GENIA.../Transponders/filename.ini

I unmounted (ejected) Win10 back in folder view. Shutdown (top right button), reboot.
Wait for dots about ten times.
Remove USB when prompted, hit Enter.
Test it out in Windows.
My App now works right, with settings updated.

I tried elevated cmd prompt:

icalcs %ProgramFiles% /restore WindowsApps.acl

No success, so I did:

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

I then followed Albin’s post above to remove control and inheritance on WindowsApps:

![Albin’s post images]

Even though it was there, Made myself owner again. I Added Administrators > check Names.
Added new user permission, check names;
Gave myself just read & execute, list folder contents, read on a second Administrator entry;
And deleted full control entry for me.
I changed owner back

NT Service\TrustedInstaller > check names
Becomes TrustedInstaller

I then hit apply and close out.
My apps still work.

zx485
  • 2,170
  • 11
  • 17
  • 24
2

I have solved this myself nonetheless:

From an administrator command prompt the following command will copy the WindowsApps package folder (or any folder within):

robocopy /B /E /COPY:DAT D:\WindowsApps\xxx D:\MyTargetDir

This will copy the WindowsApps\xxx package folder on D:\ to MyTargetDir folder on D:\. This works because the /B option tells Windows to use the Backup token which ignores any permissions or limitations / policies.

After that the files need to be decrypted:

cipher /D /S:D:\MyTargetDir

Then the files can be edited.

Remove the original folder (or rename it):

mv D:\WindowsApps\xxx D:\WindowsApps\xxx_

And then copy back the edited files:

robocopy /B /E /COPY:DAT D:\MyTargetDir D:\WindowsApps\xxx

HOWEVER: Note, I still haven't figured out how to make the edited app start, as for now Windows Store will return errors for the apps in these folders as soon as the permissions are changed. Changing them back won't work.

Gizmo
  • 1,939
  • 6
  • 30
  • 56
  • How did you're WindowsApps-Folder change from "C:\Program Files\WindowsApps" to "D:\WindowsApps" in comparison to the original quesiton? – Albin Oct 09 '18 at 09:06
  • @Albin you can go to `Settings -> Storage -> Change where new content is stored -> New apps will save to` to separately install a new app on for example D:\ so experimenting is possible without destroying your original WindowsApps folder. – Gizmo Oct 09 '18 at 09:51
  • ah, ok, I thought you managed to move the whole WindowsApps somehow. In Order for the store not to show errors you need to restore the metadata of the files (like security settings etc.) to the original values then it should work without any errors. Using DAT as copy parameters doesn't copy "all" of them, so you need to reapply them or use different copy parameters (look [here](https://techjourney.net/robocopy-syntax-command-line-switches-and-examples/)) – Albin Oct 09 '18 at 10:16
  • Yeah I copied DAT specifically so it wouldn't interfere with editing the files at the copied location because DATSU would also restrict editing. – Gizmo Oct 09 '18 at 11:12
  • I see, but then you have to reapply the security settings of the files (and possibly whatever other metadata gets lost during copying) in order to get rid of the error (anyway I like you're approach, very creative). Maybe you could try to copy the files with all the matadata and then try changing the ownership manually via UI or Commandline? What happens if you try to access the files after the change? – Albin Oct 09 '18 at 11:18
  • @Albin, look, taking ownership is not going to work and if that's the case for you then I don't know what it is or how that is possible. I Keep getting Access is denied errors even when I'm TrustedInstaller or SYSTEM. I leave this video here as proof (10 minutes): https://streamable.com/ql32s The other problem is that whenever anything is changed to the WindowsApps folder, any apps refuse to launch that are within that folder. Restoring permissions doesn't work either. Sorry the video is so "slow", I was doing your instructions EXACTLY. – Gizmo Oct 11 '18 at 18:08
  • For a game like forza demo even robocopy /b won't work.. so can't even mod the handling or textures – Gizmo Oct 11 '18 at 20:21
  • Thanks for the vid, I replyed in the comment under my answer, so we don't have several threads going. – Albin Oct 11 '18 at 22:16
  • 1
    "I still haven't figured out how to make the edited app start," So you haven't really solved your problem. Please don't post answers that don't work. – DavidPostill Oct 14 '18 at 11:37
  • I made a script to restore all the crap required for the apps to launch again: https://github.com/AgentRev/WindowsAppsUnfukker – AgentRev Nov 11 '21 at 07:04
1

There is a solution: you have to change the ownership of the files/folders. Here you can see the description including screenshots (there's already a copy on superuser as well). I just tried it on Win10 Creating/Editing/Deleting Files is possible.

If you want to reverse the ownership change you can find a description here. After changing it back you're user will still have access to the folder, removing all other security changes (like changed permissions) that were made during the ownership change will fix that to it's original state.

Important: In some cases the Store (or the Apps) wont function after changing the ownership and changing it back, unless you remove "all" changes not just the ownership. So make sure to create a system restore point unless you know exactly what you are doing!


Here's a copy of the description to change the ownership:

  1. Type in C:\Program Files\WindowsApps in the Windows Explorer address bar and hit enter.

    Enter path

  2. Observe in shock and dismay the system dialog saying you don’t own a folder on your own machine. Hit "Continue."

    Denied

  3. After hitting "Continue," you’ll be confronted by the following dialog:

    Denied again

    Do not hit "Close"—instead click the "security tab" link.

  4. In the following system dialog click "Advanced."

    Properties

  5. Click the "Change" link in the owner security field.

    Change

  6. Add in your Live ID or Windows 8 user name to the "Select User or Group" system dialog.

    Add user

  7. Click "OK," "OK," and "OK."

    Done

Albin
  • 9,307
  • 11
  • 50
  • 89
  • 3
    This is not an answer to the question as this does not work. You seem to assume that the WindowsApps folder seems to honor the ACLs, which it does not (entirely). Download "Chess Free" to for example D:\ so you don't screw up your real WindowsApps folder. Do your steps and you won't be able to edit the game files. I will only give ab ounty to a solution that successfully allows me to edit files. Or even just copy them to my own desktop. This answer does not work for that. Copying a folder from WindowsApps to Desktop will yield (on a single pc not connected to a domain) and error. – Gizmo Oct 09 '18 at 07:29
  • @Gizmo what do you mean by "download Chess Free for example D:\"?? Changing the ownership allows me to create new Files/Folders as well as edit existing Files/Folders or copy them to the desktop etc. That's what you want to do, right? If it doesn't work for you, could you please explain what happens after you apply this solution and, for example, try to create a Folder or File in "C:\Program Files\WindowsApps" (or any subfolder)? – Albin Oct 09 '18 at 08:36
  • @Gizmo I'm unable to check reproduce you're problem. This method allows me to edit existing files (previously existing to the change) as well as adding new files as well as copy existing files to a different location. Could you please specify you're problem? What exactly is the error message? Thank you! – Albin Oct 11 '18 at 15:38
  • 2
    I keep getting "Access is denied". – Gizmo Oct 11 '18 at 19:32
  • @Gizmo Thanks for the upload. I looked at the error message, it says that you didn't take ownership of the object. There could be several reasons for this (for example that the ownership wasn't transferred to all sub-objekts correctly). Before you edit the file could you check if you have ownership and you're username is listed under "permissions" (for read, write, list etc. access) as well? – Albin Oct 11 '18 at 22:08
  • 1
    My account has "Full Control" of all objects (via inheritance) – Gizmo Oct 12 '18 at 09:41
  • @well, s.th. still didn't work with changing the ownership if you are still getting the same message. If you check the ownership of the file directly what does it say? Maybe you could make a screenshot of the "Advanced Security settings" for the file you want to edit (make sure you scroll down so you're user can be seen as well)?! – Albin Oct 12 '18 at 10:11
  • Yep, this just doesn't work, at all. You can view the files, but not edit them. – BlueRaja - Danny Pflughoeft Jun 16 '19 at 01:48
  • @BlueRaja-DannyPflughoeft It worked on my test system (Win 10 Pro 1803) maybe it does not on newer versions. Which Windows version are you using? Are you sure you did it right? Which permissions did you set, for which user and which user are you using to edit? – Albin Jul 17 '19 at 23:25
0

Simple alternative solution

I got tired of fighting the NTFS file/folder permissions in Windows a few years ago.

They aren't technically advanced. Neither should they be. Simple flags in the filesystem metadata plus rules configured in the OS.

Simple things made complicated and annoying by bad management tools and nerfed admin accounts.

Less annoying read/write access

  • Most Linux distributions have full NTFS support by now.
  • Most also ignore NTFS ownership/access rules when running as a Live OS
    (from USB or DVD/CD).

Linux Mint

Note:
USB thumb drive is required for the steps below.
It's contents will be overwritten.

Linux Mint is one of many distros you can download and use for free.

  • Simple and intuitive for Windows users.
  • Normal Desktop and "Start Menu" interface. Screenshot
  • Full FAT32 and NTFS support.

How?

  • Download an ISO from the official site
  • Download a tool like Rufus or unetbootin
    Then use it to write the ISO your USB drive.
  • Reboot your computer with the drive plugged in.
  • Hit the key to show boot menu or BIOS/UEFI, then select your USB as boot device.
    Which key depends on the computer OEM/Series/Model.
  • When you see the Mint desktop:
    • Open the drive.
    • Modify files/directories as you want.
    • Shut down/reboot in any sane manner.
  • Revert BIOS/UEFI changes (if you made any) and boot Windows.

Not simple?

If you never used Linux or booted from USB, it may seem a bit intimidating, but it's really not that bad.

If you keep Linux Mint on the USB, then rebooting to make changes can be done in a few minutes the next time.

Such a USB is also a great tool if (when) Windows stops working some day.
Perhaps after updates etc.

It could be used to copy files from un-bootable computers, or to repair/fix what ever made it un-bootable.

svin83
  • 659
  • 4
  • 12
0

I've tested all solution to edit file for Age of Empire IV, even the linux one ! But it doesn't work, the directory is corrupted ... we can just move it to the trash :/

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 07 '21 at 19:57
  • Agreed. Better to move the entire Window$ to trash. – Sнаđошƒаӽ Mar 22 '23 at 17:31
0

I've seen and tried many ways, but only one method has never disappointed me until now: MoveFileEx with the flag MOVEFILE_DELAY_UNTIL_REBOOT. It executes the copy operation early during the next reboot.

If you don't want to write a program (C++, C#), you can do it with a PowerShell script. For example, to copy "test.txt" from C:\temp into MSPaint's WindowsApp directory:

Add-Type -TypeDefinition @"
    using System;
    using System.Diagnostics;
    using System.Runtime.InteropServices;
 
    public static class MyKernel32
    {
        [DllImport("kernel32.dll", CharSet=CharSet.Unicode)]
        public static extern bool MoveFileEx(
            String lpExistingFileName,
            String lpNewFileName,
            uint dwFlags);
    }
"@


[MyKernel32]::MoveFileEx("C:\Temp\test.txt", "C:\Program Files\WindowsApps\Microsoft.MSPaint_2022.2203.1037.0_neutral_~_8wekyb3d8bbwe\test.txt", 5)

This will schedule the "move" operation for the next reboot.

Pay attention to the following:

  1. Since this is a "move" operation, the file will really be moved, meaning it will no longer exist in C:\temp.
  2. MoveFileEx cannot work across drives. Both paths (source and target) must be located on the same drive (maybe even on the same partition, I'm not sure)

Deleting files from WindowsApps directory seems to be easier. It can usually be done from Windows Explorer started as administrator. Or use Sysinternal's psexec to start a DOS-prompt under System-account:

psexec -s cmd.exe

This also gives you a lot of power. But unfortunately, usually not enough to simply use the "copy" command.

Vanja
  • 1
-2

I found a simple solution, after try a lot of things, I discover a problem in the folder name (special character like ~), try rename the main app folder to a simple name like "folder1" (save the original name in notepad before), copy or replace the files and come back the main app name folder to original name.

Other thing, look if windows "LongPath" register is enabled, why sometimes subfolder have more than 255 characters

Roberto
  • 1
  • 1
  • 1
    Please add further details to expand on your answer, such as working code or documentation citations. – Community Sep 06 '21 at 20:53