Lock Folders in Windows - gHacks Tech News

Lock Folders in Windows

Windows has no obvious method to lock folders, even administrators have no options to lock folders. Locking refers to preventing access to specific folders on the system. This can for instance be important if you have children who access the computer as well, so that they do not modify it in a way that breaks it or delete important data stored on it.

Locking folders can be easily done with just two batch files that protect the contents. This is no fool proof method of course and everyone who is computer savvy can reverse this easily. You need to create two text files, add one line of code to each and save them as .bat files so that they can be run on the system.

Add the following line to the first text file ren xxxx xxxx.{21EC2020-3AEA-1069-A2DD-08002B30309D} .Replace xxxx with the folder or drive name and save the file with the extension .bat, name it protect.bat for instance.

Now add the following line to the second text file and rename it unlock.bat. ren xxxx.{21EC2020-3AEA-1069-A2DD-08002B30309D} xxxx. Replace xxxx again with the orginal name of the folder.

To lock a folder just click on protect.bat, to unlock it again click unlock.bat. (source: tech-buzz)

Update: Newer versions of Windows come with options that improve this process a lot. Here are a couple of options that you have at your disposal:

  1. Create different user profiles and limit their access. You can limit a user's folder and file access right in Windows so that they may only be able to read files but not delete or modify them, or not access them at all.
  2. Use encryption. A program like True Crypt enables you to create an encrypted container on your system that you can move all import files into so that they cannot be accessed by unauthorized users.

We need your help

Advertising revenue is falling fast across the Internet, and independently-run sites like Ghacks are hit hardest by it. The advertising model in its current form is coming to an end, and we have to find other ways to continue operating this site.

We are committed to keeping our content free and independent, which means no paywalls, no sponsored posts, no annoying ad formats or subscription fees.

If you like our content, and would like to help, please consider making a contribution:

Comments

  1. Tobey said on February 5, 2007 at 6:31 pm
    Reply

    Or you can just restrict access to those folders. But that’s less effective of course.

  2. Luke said on February 6, 2007 at 5:48 am
    Reply

    How about:

    cacls FOLDER /R USER

    This will prevent USER from ever accessing FOLDER. Alternatively you can do:

    cacls FOLDER /G Administrator:F

    This will overwrite the default settings and make Administrator the only user allowed to touch it.

    1. Shyborg said on February 8, 2007 at 11:37 am
      Reply

      Hey! LUKE.. How can we undo the process???? i cant even access to my folder. wtf..

    2. Shyborg said on February 8, 2007 at 12:19 pm
      Reply

      i used this command line “cacls FOLDER /G Administrator:F” then it locked my whole folder and now how should i Unlock it? I dont have any idea!

      1. Martin said on February 8, 2007 at 1:22 pm
        Reply

        not sure but it could be cacls Folder /P User:F

  3. Martin said on February 6, 2007 at 3:55 pm
    Reply

    This is pretty nice Luke, where did you find the information ?

  4. Luke said on February 6, 2007 at 4:15 pm
    Reply

    I think I found this when I was trying to set up private folders on a WinXP Home box. The home edition does not have the permissions tab in the file properties dialog, so the only way you can set file permissions for individual users is via cacls.

    Not sure where I found it exactly, but one of the best websites that explain all the windows command line commands is http://www.ss64.com/nt/

    They cover all the build in stuff, as well as a lot of the stuff that comes in different Microsoft administrator kits and etc.

  5. Luke said on February 8, 2007 at 3:40 pm
    Reply

    Shyborg, you would have to restore privledges for yourself – for example:

    cacls FOLDER /E /G Shyborg:F

    The /E switch means that you are editing the privs – not replacing them. If you are a part of a domain you may need to do:

    cacls FOLDER /E /G DOMAINShyborg:F

    Best way to do this is to look at another folder’s permissions and then replicate them on tour secret folder:

    cacls OTHER_FOLDER

    See which users have what permisions and just restore them using separate cacls commands. Don’t forget to use /E every time.

    Good documentation of cacls is here: http://www.ss64.com/nt/cacls.html

  6. Ranjith said on May 13, 2007 at 11:29 am
    Reply

    Nice stuff, thanx

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

Please note that your comment may not appear immediately after you post it.