Get access to the %ProgramFiles%\WindowsApps folder and view apps source code

One of my preferred ways to learn new things is to read source code written by other people. Specifically on Windows 8 Windows Store apps, I like to understand how some apps were developed, which APIs or libraries were used, and even how some page layouts were designed.

All Windows Store apps that we install through the Store app are physically stored in the folder %ProgramFiles%\WindowsApps, as I mentioned in a previous post, and inside that folder there are several sub-folders, each representing one specific app.

Inside of each app folder, there are all the files needed for the application to run, including XAML files, executables and assemblies, for apps developed in XAML/.NET or C++, and HTML, JavaScript, and CSS files for applications written in these languages.

However, the access to the folder %ProgramFiles%\WindowsApps is blocked to a normal user, and the only user with permissions to access and change the contents of that folder is an user called “TrustedInstaller“, which is used by Windows for installing and uninstalling Windows Store apps. This user is the “owner” of that folder, and thus has full control.

This is how the permissions of the folder %ProgramFiles%\WindowsApps are defined by default:

A folder can only have one “owner“, and only the owner of the folder can assign permissions to other users. Therefore, in order to get access to the folder %ProgramFiles%\WindowsApps, we need to follow these steps:

  1. Assign the ownership of the folder to the current logged user (and since a folder can only have one “owner“, the “TrustedInstaller” is no longer the “owner” of the folder);
  2. Assign permissions to access the folder to the current logged user;
  3. Assign the ownership of the folder back to the “TrustedInstaller” user, so that apps can continue to be installed/uninstalled without problems.

To change the ownership of the folder WindowsApps, we need to open a Command Prompt with administrative rights, and use the command takeown, but first it is a good idea to backup the current permissions of the folder, so that in case something goes wrong we can restore the permissions exactly as it were before:

@REM Backup current folder permissions to a temporary file
icacls "%ProgramFiles%\WindowsApps" /save "%TEMP%\WindowsApps.acl" /Q

@REM Assign the ownership of the folder to the current logged user
takeown /F "%ProgramFiles%\WindowsApps"

At this moment, the current logged user is the new “owner” of the folder WindowsApps. In the image above you can see that it is my user “Caio Proiete”.

The next step is to assign proper permissions on the folder to the current logged user, and in this example I’m assigning full control on the folder:

@REM Assign full control on the folder for the current logged user
icacls "%ProgramFiles%\WindowsApps" /grant "%username%":F /Q

Finally, we assign the ownership of the folder back to the “TrustedInstaller” user, to make everything be like it was before, except that now our user has access to the folder too:

@REM Assign the ownership of the folder back to the "TrustedInstaller" user
icacls "%ProgramFiles%\WindowsApps" /setowner "NT Service\TrustedInstaller"

At this moment, if you didn’t get any error message, you should have full control over the folder WindowsApps.

This is how the permissions of the folder %ProgramFiles%\WindowsApps are defined after doing the steps above:


If something went wrong

If the process above didn’t work and you got error messages or something, you can always choose to restore the original permissions from the backup that you did in the beginning:

@REM Restore the original permissions of the folder "WindowsApps"
icacls "%ProgramFiles%" /restore "%TEMP%\WindowsApps.acl" /Q


Full script ( GrantAccess-WindowsApps.cmd )

@echo Backing up current folder permissions to a temporary file
@icacls "%ProgramFiles%\WindowsApps" /save "%TEMP%\WindowsApps.acl" /Q
@if ERRORLEVEL 1 goto rollback

@echo Assigning the ownership of the folder to the current logged user
@takeown /F "%ProgramFiles%\WindowsApps"
@if ERRORLEVEL 1 goto rollback

@echo Assigning full control on the folder for the current logged user
@icacls "%ProgramFiles%\WindowsApps" /grant "%username%":F /Q
@if ERRORLEVEL 1 goto rollback

@echo Assigning the ownership of the folder back to the "TrustedInstaller" user
@icacls "%ProgramFiles%\WindowsApps" /setowner "NT Service\TrustedInstaller"
@if ERRORLEVEL 1 goto rollback

@goto success

:rollback
@echo.
@echo Error! Rolling back...
@icacls "%ProgramFiles%" /restore "%TEMP%\WindowsApps.acl" /Q
@echo.
@echo Check the error messages above to see why it didn't work
@echo Did you forgot to run as administrator?
@goto end

:success
@echo.
@echo Success! You should have access to the "%ProgramFiles%\WindowsApps" folder
@goto end

:end
This entry was posted in Windows 8 and tagged , , , , , . Bookmark the permalink.

10 Responses to Get access to the %ProgramFiles%\WindowsApps folder and view apps source code

  1. Pingback: Physical location of Windows Store applications and data on a PC | Caio Proiete (EN)

  2. everal says:

    Thanks for your great script.
    Works perfect on “Surface RT” OS “Windows RT”

    Very Thanks…

  3. PaulSk says:

    Using new Desktop PC with Windows 8 Pro with mediacenter. Followed your instructions. Worked excelent. Tnx!

  4. Joe Marcheski says:

    Excellent guide. Good example for all global helps. Thanks!

  5. Moofey says:

    Awesome. Because I didn’t do the backup at the beginning my folder permissions are officially screwed up.

    “This security ID may not be assigned as the owner of this object” when trying to revert ownership back to trustedinstaller.

  6. Moofey says:

    Update: Nevermind. I forgot I was using my standard cmd instead of my admin cmd.

  7. san says:

    Please could any one let me know the silent command to restore the owner ship to “Trusted installer” as a default owner. steps i performed is :

    1- TAKEOWN /R /F “C:\Program files” (SUCCESS & now i could see owner is SYSTEM)
    2 – cacls “c:\Program files” /T /E /G ProgFiles:W (ProgFiles is the local group) – SUCCESS

    Now here i tried below to restore the ownership:
    icacls “C:\Program files” /setowner “NT SERVICE\TrustedInstaller” /t /c
    ( It gave me message saying , successfully processed 897 files, failed processing 1134 files. (and still i could see SYSTEM as owner and not Trusted installed). PLEASE HELP ME

  8. ViBE says:

    i followed your tutorial and it’s okay. and i have the same rights now. but i still cannot edit/create files in the subfolders. how can i make t possible while not harming any other rights?

    • FutureNipples says:

      Microsoft locked this folder down in Windows 8.1 to prevent tampering with Metro apps. I’ve yet to find any way to modify anything in the WindowsApps folder using Windows 8.1

  9. amidmany says:

    you are a god!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>