Lock Files and Folders in Windows Without Extra Software

We have previously written about a utility used to lock files and folders in Windows, How to Protect and Lock Folders in Windows. Here is a method for locking files and folders without having to install a third-party software program.

Download the following text file, which contains the code for the batch file:


Open the file in Notepad. Replace “type your password here” in the LockCode.bat file with the password you want to use to lock and unlock the protected files and folders. DO NOT forget this password. Save the file as LockCode.bat.

NOTE: We realize this seems unsecure to enter your password in plain text into a text file, but this will be discussed later.

Text of LockCode.bat file

You should now have two files: LockCode.txt and LockCode.bat. If you cannot tell which file is which because the file extensions are not displaying, select Folder Options from the Tools menu in either My Computer or Windows Explorer.

Selecting Folder Options from the Tools menu

On the Folder Options dialog box, click the View tab, scroll down to the Hide extensions for known file types option and uncheck the check box.

Showing extensions for known file types

Now you should be able to see the extensions for both files.

File extensions on the files

Double-click on the LockCode.bat file to create a new folder named Locker. The new folder is created in the same directory as the LockCode.bat file.

Locker folder created

Place any files and other folders you want to protect into this Locker folder. Double-click the LockCode.bat shortcut on the desktop again to lock the Locker folder. You are asked if you are sure if you want to lock the folder. Type a Y if you are sure you want to lock the folder. The folder disappears.

Confirmation of locking the Locker folder

To unlock the Locker folder again, double-click on the LockCode.bat file. You are asked to enter your password.

Enter password

The folder is available again.

To make this a more secure option for locking files and folders, once you have locked the Locker folder, open the LockCode.bat file in Notepad and remove your password. You may either leave it blank or enter a dummy password. Only when you are ready to unlock your files and folders, should you open the LockCode.bat file again and re-enter your password and save the file again.

Then, you can double-click on the LockCode.bat file to unlock the Locker folder. If you don’t take this precaution, anyone can open your LockCode.bat file and view your password.

To open a .bat file in Notepad, you must open Notepad first. If you double-click on the file like you would if you were opening a text file, the file runs instead of opens.

Once Notepad is open, select Open from the File menu. Select All Files from the Files of type drop-down list to be able to see the LockCode.bat file. Then, you can click Open to open the file.

Opening a batch file in Notepad

To protect your password, you can also delete the LockCode.bat file and create it again from the original LockCode.txt file when you need to unlock your files.

NOTE: The LockCode.bat file MUST be in the same directory where the Locker folder was created originally for this method of locking files and folders to work. [via Rakshit Khare’s Blog]

by Lori Kaufman

Comments [8]

  1. That is one of the worst ideas I've ever read. You are just marking the folder as hidden and system, and it is not actually "locked" in any sense at all. The only reason it is not shown anymore is by virtue of the windows folder settings being currently set to not show system files and folders.

    Not only that but you are advocating saving a "password" in completely plaintext, and I use the term "password" loosely, as it is possible to circumvent your method of hiding the folder without knowing it at all.

    Do people a favour and don't suggest a solution to such a problem which doesn't actually do anything like what you claim it does. If anything, it actually makes the system less secure, if like many people the user uses the same password everywhere. They have now put their password in a plain text file for anyone to observe.

  2. To add to oliver's comments, your suggestion of protecting the password is moot. Anyone who can read and understand what the script can easily figure out the "password" is not necessary.

  3. This isn't secure, it's just obfuscation. And it will still end up in file scans.

    It would be better if you put the password in a separate location (eg a USB key) but even then it's pretty bad. If I see LockCode.bat I'm going to know exactly how to get their files.

  4. I agree with Oliver… this isn't a valid solution by any stretch of the imagination…The password provides nothing at all, since it only actually matches for a password when you open the batch file to tell it to ask for a password……

    The exact same solution without being quite as retarded would be to replace the entire IF/GOTO line with:

    if 1==2 goto FAIL
    1==1 means it cant unlock the file
    1==2 means it will always unlock the file
    (Since your editing the file to put your password in anyway!)

    Then at the very least this will block the computer illiterate from accessing your folder…

    Better yet, right click folder, click properties, tick "hidden". Then to view/hide it, enable/disable the view hidden folders option in Windows? Same thing…

  5. Following my previous post… it appears there is at least some cleverness in this approach. When you rename a folder to "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}", it becomes a link to control panel (so "opening it will not access the folder contents). Simply changing the name to something else unlocks it though, so still very insecure for people who know what they're doing.

    If people are serious about their file security then they should use truecrypt. (google it)

  6. Furthermore, it doesn't even have to have the "Control Panel" in front of the ".{…}" it can be any word. It's the ".{…}" that makes it "hidden".

    I used to use a program built in VB, a long time ago, that did the same thing.

  7. This is an impressive hack… if you're a clueless 11 year-old trying to hide pictures of boobies from your parents.

    Unfortunately this site claims to offer Computer Tips for IT Pros and in that context it is a contemptibly stupid suggestion.

  8. as far as I can tell, any script kiddie could open your bat, input their own pass and then "unlock" your file with that pass.


    If you want a fast/easy way to hide files and it doesn't need to be secure, then make a hidden partition on your drive.

    accessing the drive is as easy as entering the drive path in an explorer directory line. This should keep all computer illiterates out and even the occasional geek (as long as they don't have any reason to be checking your partition table).

    and of course if you want the secure method, you can use truecrypt. It does cost you a bit of performance though and it is a bit more of a hassle, so it's a tradeoff of security vs ease-of-use

Leave a Reply

Your email address will not be published. Required fields are marked *