13

UPDATE While I was able to use the method described in accepted answer once it failed a second time or was just giving too much trouble.

Searching further I found SetACL by Helge Klein which is far far superior and does exactly what is needed.


I cannot access certain folders e.g. c:\Program Files\WindowsApps. Via command line I get an error of "Access is denied" and via Windows Explorer I get a pop up a dialog box stating "You don't currently have permission to access this folder"

enter image description here

Clicking on Continue gives me access, but I would like to grant myself access using the command line; so that my scripts do not run into this problem running under the same security context.

I found this question on Microsoft Technet but I couldn't get it to work. Note that I am already running Powershell as administrator.

PS C:\WINDOWS\system32> icacls "C:\Program Files\WindowsApps" /grant i063510:F /inheritance:e
C:\Program Files\WindowsApps: Access is denied.
Successfully processed 0 files; Failed processing 1 files
PS C:\WINDOWS\system32> icacls "C:\Program Files" /grant i063510:F /inheritance:e
C:\Program Files: Access is denied.
Successfully processed 0 files; Failed processing 1 files

If it matters, I am using Windows 10 upgraded from Windows 8.1.

12

You don't currently have permission to access this folder

Try ICACLS and/or TAKEOWN with the below syntax against the folder with the username as needed.

Try just the ICACLS commands first and if that doesn't resolve, run the TAKEOWN commands and then run the ICACLS commands again.


ICACLS Commands

  • Grant explicit full control access to this folder to all beneath subfolders, and files leaving all inherited permissions in place and continue on error

    ICACLS "<FolderPath>" /INHERITANCE:e /GRANT:r <UserName>:(F) /T /C
    
  • Grant explicit modify access to this folder to all beneath subfolders, and files leaving all inherited permissions in place and continue on error

    ICACLS "<FolderPath>" /INHERITANCE:e /GRANT:r "<UserName>":(M) /T /C
    
  • Change the owner of this folder and all beneath subfolders and files and continue on error

    ICACLS "<FolderPath>" /SETOWNER "<UserName>" /T /C
    

TAKEOWN Commands

  • Run this as the account which you want to grant ownership to, and it'll be changed to the owner of the folder and all beneath subfolders and files

    TAKEOWN /F "<FolderPath>" /R /D Y
    
| improve this answer | |
  • Thanks. I want to avoid TAKEOWN / SETOWNER. I am assuming that it changes the owner and Windows Explorer only assigns permission. – Miserable Variable Jul 13 '16 at 22:13
  • Can you confirm if just the ICACLS "<FolderPath>" /INHERITANCE:e /GRANT:r "<UserName>":(OI)(CI)(X,M,F) /T /C will then give you the expected result? I'll update my answer with more detail if so. – Pimp Juice IT Jul 13 '16 at 22:14
  • You have to take ownership of that folder if you want permissions to that specific folder, any other folder, you could avoid taking ownership – Ramhound Jul 13 '16 at 22:14
  • This works for me: ICACLS "C:\Program Files\WindowsApps" /INHERITANCE:e /GRANT:r i063510:F /T /C. Thanks for your help. @Ramhound I could not understand from your comment when I do or do not need to take ownership. – Miserable Variable Jul 13 '16 at 22:16
  • @MiserableVariable I just updated my answer with further detail as well. – Pimp Juice IT Jul 13 '16 at 23:13

Not the answer you're looking for? Browse other questions tagged or ask your own question.