How to Place a Password Lock on a Folder in Windows 10

Windows Lock Folder Featured

One of the biggest issues with sharing your computer with others is that it is difficult to keep any files private. Fortunately, Windows 10 allows you to create a password lock on a folder so that only you and the people you trust with the password are able to access it. Here are the steps to set up a password-locked folder.

Creating a Locked Folder

1. Create a new folder on your computer.

2. Open the folder, and right-click inside it.

3. Select a new text document to add to the folder. Name the document Password file or any other name you prefer and then open it.

4. Now you need to copy and paste the following code into the text document:

cls
 
@ECHO OFF
 
title Folder Locker
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
if NOT EXIST Locker goto MDLOCKER

:CONFIRM
echo Are you sure u want to Lock the 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.goto CONFIRM

:LOCK
ren Locker "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
 
echo Folder locked
 
goto End

:UNLOCK
 
echo Enter password to Unlock folder
 
set/p "pass=>"
 
if NOT %pass%== mypassword goto FAIL
 
attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
 
ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" Locker
 
echo Folder Unlocked successfully
 
goto End

:FAIL
 
echo Invalid password
 
goto end

:MDLOCKER
 
md Locker
 
echo Locker created successfully
 
goto End

:End

5. In the 22nd line of the code, change the word “mypassword” to whatever password you wish to use for the folder. Make sure to leave a single space before and after the password.

Folder Lock Password Change

6. Go to the top of the text document and select the File option. Tap on “Save As.”

7. In the new window that opens, save the file type as All Files, and change the name of the file to Lock or any other name you wish, but make sure to add the extension .bat at the end of the file name. Hit save and exit the text document.

Folder Lock Save As Bat

8. A new batch file will now appear inside the folder carrying the name you choose in the previous step. Double click on this file to reveal a new folder that pops up. Drag and drop all the files you wish to keep private inside this new secret folder except for the .bat file.

9. Once again, double click on the .bat file, and a new window will pop up asking if you are sure you wish to lock the folder. In the space below it, type “Y” in uppercase and hit Enter. The folder has now been locked and will disappear.

Folder Lock Confirmation Messa

10. The folder you created in the first step will still be visible in its original location. Go inside the folder, and you will find the .bat file waiting for you. Double-click on the file, and enter the password you chose earlier in the new window that pops up and hit Enter.

Folder Lock Enter Password

11. The hidden folder containing your private files will appear on the screen. You can access the files just as you normally would and use them freely.

12. When you are done using the files, go back to the previous folder and double-click on the .bat file again. The program will again ask if you wish to lock the folder. Once again, type uppercase “Y” and hit Enter, and the folder will be locked.

Repeat this process for as long as you wish to keep using the password-protected folder.

Conclusion

The password-protected folder is a good method of keeping certain files private while using a computer that other people also have access to. Make sure to keep a copy of the password somewhere safe so you don’t end up forgetting the password and getting locked out of your own private stash of data.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox