≡ Menu

Windows change access permissions from the command line

Linux and Unixish system comes with chmod and other commands to setup/change access permission from command line/shell.

However, when it comes to windows chmod is not available. Windows comes with a special command line utility called CACLS.

You can use it as follows:


  • /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 /?

Share this on:

{ 25 comments… add one }

  • Top Coder - Ankit Baphna November 13, 2008, 8:08 am

    You can use *.* in place of files to change access mode of multiple files at a time.

  • Alex May 16, 2009, 7:28 am

    Super dude.. i got in a right time.. thanks for your contribution and sharing of knowledge..keep doing..

  • J. February 5, 2010, 3:02 pm

    /T is a very nice switch in case of an entire drive’s permissions getting messed up. Recursion ftw?

  • Guarantor Loans August 8, 2010, 10:37 am

    Life saver! Just used this after having problems with explorer! worked a treat! Thanks!

  • nevelis November 15, 2010, 7:30 am

    This helped me get rid of a virus – there was a process that kept spawning an executable inside of AppData\Temp, so I ran:

    cacls hki304.exe /D

    /D for “deny access”, which stopped the process from being able to be started, and then the process that was spawning this revved up to 50% CPU. Gotcha ya bastard :)

    Thanks for the tip!

  • elango November 26, 2010, 11:56 am

    thanks dude.you correct time tell the answer for me


    • Cody December 7, 2010, 8:53 pm

      Awesome, this was a life saver. I was working on a client’s PC and the host file got locked out somehow. It wasn’t visible, even while showing hidden files. I could open it through the command line but wouldn’t let me save it or edit it. Tried numerous things, scans, safemode, changing the attributes via command line, the whole nine yards. Only thing that worked was using this command.
      “CACLS hosts /p administrator:f”
      Then after that I was able to change the attributes and then edit the file back to normal. Thanks a ton OP

  • manu April 21, 2011, 12:23 am

    I tried it but, couldn’t get it done. Dont know why my command prompt accept the command I am using :(

    • Me May 20, 2011, 1:41 pm

      Did you right click and run your command prompt as an administrator?

  • Ibs June 2, 2011, 10:38 pm

    i went through your instructions as listed and the command line said this “No mapping between account names and security IDs was done” dont know what this means??

  • TameDrone June 9, 2011, 12:08 am

    I need help because while trying to shutdown another computer in my home it is saying failed to find registry and i can’t figure how to add special permissions to my thing.

  • sahamat khan June 23, 2011, 7:59 pm

    here what is the meaninig by files???

    • It is the folder name or path to that folder August 3, 2012, 2:50 pm

      C:\Users\sudheesh\Videos>cacls filims /e /p sudheesh

      syntax : > cacls — > is the keyword that does the job for you.
      filims —> is the name of the folder needed to be deleted in my case .
      /e —> stands for editing the permissions.
      /p —> stands for creating a new permission .
      sudheesh –> my username

      processed dir: C:\Users\sudheesh\Videos\Filims

  • KillerJH2 June 27, 2011, 3:59 pm

    my permissions list got scrambled so i had to delete all permissions (stupid i know)
    and now this is working but access denied
    and i want to punch my laptop so hard :L

  • MattH October 12, 2012, 5:26 pm

    I was doing some work in my Digital forensics class and accidently set my admin permission to read only. when I use this method to try and set permission it doesnt seem to change anything. How do I get my admin right back to my admin without using admin obviously to set it. System still has full access obviously so I thought that command prompt would solve this issue.

  • Job October 24, 2012, 10:27 pm

    Trying to recover data from a dead computer. Used Apricorn adapter to view IDE drive via usb connection. Am able to view and extract data from Administrative and All Users but not from user phbergh. I used the command CACLS PHBERGH /P PAUL:F and was able to cd to phbergh. I got access denied when trying to access My Documents for phbergh. I then used the command line CACLS *.* /T /P PAUL:F and after answering I was sure I received the access denied message. What am I doing wrong? Please help me.

  • Tliimfee December 22, 2012, 4:05 am

    Access is denied despite being signed in as admin? Any suggestions?

  • Cynara December 26, 2012, 5:26 am

    this works only for files in NTFS permission. How about for exFAT?

  • v March 23, 2013, 4:07 pm

    it does not worked for me. Access was denied while changing permission of a directory.

  • rakesh kumar jena May 9, 2013, 1:20 pm

    i have locked a folder in my computer by using cacls (folder name) /e /p everyone:n
    but when i want to unlock this i have used CACLS files /e /p everyone:f
    but i am unable to open this file
    please help how i can unlock this folder

  • Mark September 28, 2013, 7:32 pm

    Thank you so much!

  • mark March 29, 2014, 7:08 pm

    Bought a computer and it won’t let me add or remove programs or anything says I don’t have permission please help

  • user September 29, 2015, 5:25 pm

    Running this code to get permission is not permitted! F@#!

  • user September 29, 2015, 5:40 pm

    Granting permission is not permitted. Funny.

  • Bashed Forkbomb November 9, 2015, 1:16 am

    Just to bring some help i was reading the post which btw is extremely detailled and explicit Good job! it was usefull and have found my answer and even more knowledge about privileges under Windows OS thank you!

    Ok!! for all people who posted about permission and privileges lost for wtvr reason or because they got infected by a Virus who managed to remove you permission here a little simple and easy fix:

    1: Open notepad (Notepad++ or any other text editor will do also)
    2: copie/paste the following line:
    @echo off
    echo,Y|cacls “%WinDir%\system32\drivers\etc\hosts” /G everyone:f
    attrib -s -h -r “%WinDir%\system32\drivers\etc\hosts”

    3:Save As, and name the files: ‘wtvryouwant’.bat , Where: ‘wtvryouwant’ is wtvr you wanna call it to find it later on. The only thing that mather is to put that .bat, which gonna make it a batch files.
    4:Right click: Run as admin.
    5:Pemission should be fixed, if not reboot into Safe Mode and run it as admin again.

    If you dont know what your doing just do it the exact same way then mentioned upward, if you know what your doing just use theyse exact command 1by1 on elevated command prompt rather then going for the batch files option.

Leave a Comment