Monday, December 15, 2014

grant administrators and change access to files and folders

 icacls "e:\program files" /grant administrators:F /t

 icacls "e:\program files" /grant {USERNAME}:{PERMISSION} /t


icacls <FileName> [/grant[:r] <Sid>:<Perm>[...]] [/deny <Sid>:<Perm>[...]] [/remove[:g|:d]] <Sid>[...]] [/t] [/c] [/l] [/q] [/setintegritylevel <Level>:<Policy>[...]]
icacls <Directory> [/substitute <SidOld> <SidNew> [...]] [/restore <ACLfile> [/c] [/l] [/q]]



____________________________________________________________________




Windows comes with a special command line utility called CACLS.
You can use it as follows:
CACLS files /e /p {USERNAME}:{PERMISSION}
Where,
  • /p : Set new permission
  • /e : Edit permission and kept old permission as it is i.e. edit ACL instead of replacing it.
  • {USERNAME} : Name of user
  • {PERMISSION} : Permission can be:
    • R - Read
    • W - Write
    • C - Change (write)
    • F - Full control
For example grant Rocky Full (F) control with following command (type at Windows command prompt):
C:> CACLS files /e /p rocky:f
Read complete help by typing following command:
C:> cacls /?

http://www.vistax64.com/vista-security/112670-changing-folder-permissions-recursively.html
http://www.cyberciti.biz/tips/windows-change-access-permissions-from-the-command-line.html

Take Ownership of a Folder and Sub-Folders In Command Prompt



http://www.nextofwindows.com/how-to-silently-recursively-take-ownership-of-a-folder-and-sub-folders-in-command-prompt/

How To Silently Recursively Take Ownership of a Folder and Sub-Folders In Command Prompt

One of the first few things you might encounter after upgrading your existing Windows to Windows 8.1 is the file and folder/directory permission problem. If you have multiple disk drive, as well as multiple users or a new user for the new Windows 8.1, then you might have some of the folders become inaccessible due to the lake of permission after the system was upgraded to Windows 8.1.
You might get a warning message like the following “You don’t currently have permission to access this folder.” Click Continue to permanently get access to this folder.
You don't currently have permission to access this folder
You don’t currently have permission to access this folder
You have the choice to click “Continue”. In most case, this will fix the issue of not being able to get access to the folder. But sometimes, you might still run into issues where all the child folders have the same problem, unable to access this folder because of the lack of permission. In this case, you can manually click “Continue” for every single child directory or use a command line utility called “takeown” to achieve this.
takeown command
takeown /a /r /d Y /f D:\PATH\
Launch command prompt as administrator. You can do so in Windows 8.1, by right click on the Start Menu > Command Prompt (Admin) and type the following command. Let me explain what this command is doing, /a is telling the computer to grant ownership to the administrator/r recursively find all folders and sub-folders and files. /d Y is to answer yes to any prompt if needed, /f specific root folder you’d like to start on.
By doing so you will see messages fly by on each success permission update, “SUCCESS: The file (or folder): “…” now owned by the administrator group. You are now successfully silently updated file permission to the new system.
Success takeowner
Mission of taking folder ownership succeeded
If you don’t want to grant the permission to administrator group, just drop /a in the command and it will grant permission to the current user. This will save you tons time on file permission headaches when upgrade your system to a new OS, particularly after Windows 8.1 upgrade.

http://www.nextofwindows.com/how-to-silently-recursively-take-ownership-of-a-folder-and-sub-folders-in-command-prompt/

Monday, December 1, 2014