HomeHow ToHow to lock a folder on Winows 7, 8 and 10?

How to lock a folder on Winows 7, 8 and 10?

While you can surely encrypt a file or a folder, you cannot put a password to it.

There are certain files on our PC which we want to keep away from everyone. These might be some important pictures or some documents which you want to keep private. Strangely, Windows doesn’t allow us to lock a specific folder by default. While you can surely encrypt a file or a folder, you cannot put a password to it. There are a bunch of software available on the internet which does allow you to password protect a particular file or a folder, but they are often accompanied by various malware. However, a little labour can help you password protect a folder without installing any third party application.

Note, this trick will work on Windows 7, Windows 8 (8.1) and Windows 10.

Step 1: First, just create a new folder anywhere on your drive where you want to keep your private files or folders.

Step 2: Next, open Notepad and copy the following code to it:-


if EXIST “Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}” goto UNLOCK

if NOT EXIST Private goto MDPrivate


echo Are you sure to lock this folder? (Y/N)

set/p “cho=>”

if %cho%==Y goto LOCK

if %cho%==y goto LOCK

if %cho%==n goto END

if %cho%==N goto END

echo Invalid choice.



ren Private “Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}”

attrib +h +s “Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}”

echo Folder locked

goto End


echo Enter password to Unlock Your Secure Folder

set/p “pass=>”

if NOT %pass%== PASSWORD-HEREgoto FAIL

attrib -h -s “Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}”

ren “Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}” Private

echo Folder Unlocked successfully

goto End


echo Invalid password

goto end


md Private

echo Private created successfully

goto End


Step 3: Replace ‘PASSWORD-HERE’ with the password you want to keep and go to File > Save As > and change the file extension to .bat from .txt and choose ‘All Files’ in the save as type drop down menu. You can name the file whatever you want.

Step 4: Now double click the .bat file you just created and you will notice that a new folder just appeared with the name ‘Private’. Save all the files and folders you want to keep private in this folder.

Step 5: Double-click the .bat file once again and a CMD prompt will ask you if you want to lock the folder or not. Type ‘Y’ for Yes and ‘N’ for No.

Step 6: Once locked, you will notice that the ‘Private’ folder has now disappeared. To access the folder again, just double-click the .bat file and enter the set password.

This way you can keep all your private files at one place protected by a password. Pro Tip: Name the .bat file carefully as it shouldn’t hint that it contains your password. As a matter of fact, anyone can access your password by just changing the extension of the .bat file.

For the latest tech news and reviews, follow us on Twitter, Facebook, and Google News. For the latest videos on gadgets and tech, subscribe to our YouTube channel.



Please enter your comment!
Please enter your name here

Latest News