Sunday 3 June 2018

windows 10 - Command line to permanently get access to folder


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.



Answer




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.







  • 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 "" /INHERITANCE:e /GRANT:r :(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 "" /INHERITANCE:e /GRANT:r "":(M) /T /C



  • Change the owner of this folder and all beneath subfolders and files and continue on error



    ICACLS "" /SETOWNER "" /T /C








  • 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 "" /R /D Y



No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...