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