Skip to content

Instantly share code, notes, and snippets.

@augustoproiete
Created October 12, 2012 17:52
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save augustoproiete/3880520 to your computer and use it in GitHub Desktop.
Save augustoproiete/3880520 to your computer and use it in GitHub Desktop.
Get access to the %ProgramFiles%\WindowsApps folder and view apps source code
@REM More info:
@REM http://caioproiete.net/en/get-access-to-the-programfileswindowsapps-folder-and-view-apps-source-code/
@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
@gabrielnahmias
Copy link

Could this be adapted to a script that loops through all folders on a certain drive which disallow access?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment