Home » How To » How to Lock Folder in Windows 10 & 11

How to Lock Folder in Windows 10 & 11

You can use a batch script, NTFS encryption, or BitLocker to lock folders in Windows 10 & 11. Here’s how to lock a folder in Windows 10 & 11.

Almost everyone has important or not-so-important files that we like to hide and protect from others. In fact, using the attrib command, you can hide a folder so that it will not be visible even if someone tries to unhide folders using common methods. Apart from that, there are several ways you can lock a folder and password protect it. Below are some of the easiest methods you can use to lock folders or even drives in Windows 10.

Jump to:

1. Use Batch File to Password Protect and Lock Folder in Windows 10 & 11

The simplest way to lock a folder in Windows is to use a batch file. All you have to do is add all the contents you want to lock away in the folder created by the batch file, lock the folder, and the batch file will completely hide it from plain sight. When needed, you have to enter the password in the batch file to reveal the folder.

This method is perfect for hiding and protecting not-so-important files that you don’t want others to see. Follow the below steps, and you should have a working batch script to lock a folder in Windows.

This method is not a secure way to protect your files and folders. Anyone with a bit of knowledge about bat files or who knows where and how to look can unlock the content. To secure essential files and folders, I’d recommend following the 3rd method.

1. Open the File Explorer and go to the drive or folder where you want to store the locked folder. In my case, I’m selecting a folder called WindowsLoop in my D drive.

2. The first thing we need to do is create a batch script. You can do that with a regular text file. So, right-click in the File Explorer and select “New -> Text Document.”

Win10 lock folder with password 01

3. Rename the text file to lock.bat. You can name the file anything you want. Just make sure that the file extension is .bat, not .txt.

Win10 lock folder with password 02

4. Right-click on the newly created file and select the “Edit” option. This action will open the batch file in Notepad. Here, copy and paste the below code.

cls
@ECHO OFF
title Folder Locker
if EXIST "Locker.{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 "Locker.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
attrib +h +s "Locker.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
echo Folder locked
goto End
:UNLOCK
echo Enter password to Unlock folder
set/p "pass=>"
if NOT %pass%==ENTER_YOUR_PASSWORD goto FAIL
attrib -h -s "Locker.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
ren "Locker.{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 line 23 of the pasted code, replace “ENTER_YOUR_PASSWORD” with the actual password that you’d like to use.

6. After entering your password, select “File -> Save” to save the batch file changes. Close the file after saving it.

Win10 lock folder with password 04

7. Now, double-click on the lock.bat file.

Win10 lock folder with password 05

8. You will be prompted for a password. Type the password you’ve added in the batch file and press Enter.

Win10 lock folder with password 06

9. As soon as you press the Enter button, you will see a new folder called “Locker” in the same folder as the batch file.

Win10 lock folder with password 07

10. You can save any number of files or folders in the Locker folder. As you can see from the image below, I’ve stored my super-secret folder in the Locker folder.

Win10 lock folder with password 08

11. Next, execute the lock.bat file again. You will be asked whether you’d like to lock the folder. Type Y and press Enter.

Win10 lock folder with password 09

12. Just like before, the folder is completely hidden from plain sight.

Win10 lock folder with password 10

If you want access to the locked folder, execute the batch file again, enter the password, and you will see the locked folder.

2. Encrypt and Password Protect Folders Using NTFS Advanced Permissions

Note: You need to be using the Pro version of Windows. Moreover, the file system should be NTFS.

Windows 10 lets you natively encrypt a folder’s contents with your user account password. Since Windows uses your user account to encrypt the folder, other users on your system cannot access the contents of the encrypted folder. Only you can access the folder by logging into your user account. If your system only has a single user account, then create another one for other users and change the password for your user account so that only you can log into your user account.

1. First, verify that the folder you want to protect is located in an NTFS formatted drive. To do that, right-click on the drive and select “Properties.” You will see the drive file system next to “File System.” It should be saying “NTFS.” If it doesn’t say “NTFS,” you will not be able to follow this method.

Win10 lock folder with password 11

2. Now, create a folder in the NTFS drive. Right-click on the folder and select the “Properties” option.

Win10 lock folder with password 12

3. In the folder properties window, click on the “Advanced” button.

Win10 lock folder with password 13

4. Now, select the checkbox “Encrypt contents to secure data” and click on the “Ok” button.

Win10 lock folder with password 14

5. Click on the “Apply” and “Ok” button in the main folder properties window.

Win10 lock folder with password 15

6. As soon as you apply the changes, you will see a notification to back up the private key. This is not essential. However, backing up allows you to recover data stored in the encrypted folder if you lose access to your user account. Click on the “Notification.”

Win10 lock folder with password 16

7. To back up the private key, click on the “Back up now” option and follow the wizard. Once you are done backing up, you should see the key file in your Documents folders. Follow the following steps after completing the backup.

Win10 lock folder with password 17

8. Now, copy the files and folders you’d like to lock up. Files added to the encrypted folder have a little lock icon. Since your user account encrypts the folder, you can use the encrypted folder like any other folder.

Win10 lock folder with password 18

9. If any other user from other user accounts tries to access the contents of the encrypted folder, they will be greeted with an error message like the one below.

Win10 lock folder with password 19

Keep in mind that this method is better than the first one; however, it is still not perfect. So, don’t store important files using this method. That being said, it still is an excellent method to lock not-so-important files that you don’t want others to see.

3. Use  BitLocker to Encrypt, Password Protect, and Lock Folders in Windows

Windows 10 Pro version has a built-in powerful encryption tool called BitLocker. You can use the BitLocker tool to encrypt entire drives. Once encrypted, it is almost impossible to get access to the contents of the encrypted drive without proper authorization. To encrypt a drive using BitLocker, follow the below steps.

1. Open the start menu, search for “Manage BitLocker,” and open it.

Win10 lock folder with password 20

2. The BitLocker Management screen will list all the available drives. Find the drive you want to encrypt and click on the “Turn BitLocker On” link next to it.

Win10 lock folder with password 21

3. You will be asked to choose the authentication type. In my case, I’m selecting password authentication. So, select the “Use a password to unlock the drive,” enter your password, and hit the “Next” button.

Win10 lock folder with password 22

4. For recovery purposes, you will be asked to back up the recovery key. Click on the “Save to a file” option. You can also save the backup key to your Microsoft account by clicking the “Save to your Microsoft account” option.

Win10 lock folder with password 23

5. Select the destination where you’d like to save the recovery key. In my case, I’m selecting the desktop location. Keep this file safe and secure so that if you ever forgot the BitLocker password, you can use this file to decrypt the drive and access the contents.

Win10 lock folder with password 24

6. In the BitLocker wizard, select “Encrypt used disk space only” and click on the “Next” button.

Win10 lock folder with password 25

7. Select “Compatible mode” and click “Next.”

Win10 lock folder with password 26

8. Click on the “Start encrypting” button. Depending on how much data there is in the drive, it can take time to complete the encryption process. So, it back and wait.

Win10 lock folder with password 27

9. Once the drive is encrypted; you will see a lock icon on the drive icon in the File Explorer. You can use it as your regular drive.

Win10 lock folder with password 28

10. Every time you log into your system, you will see a locked drive. To unlock the drive, double-click on it.

Win10 lock folder with password 29

11. You will be prompted to enter the BitLocker password. Enter the password, and the drive will be unlocked and decrypted so that you can use it like any other drive.

Win10 lock folder with password 30

That is it. It is that simple to encrypt a drive with BitLocker in Windows 10. If you are looking to protect important files and folders, this is the method you should be using.

Lock Folder in Windows 10 – Conclusion

As you can see, there are multiple ways to protect files and folders with a password in Windows 10 & Windows 11. Use the first method for files that you’d like to hide from plain sight. Use the second method for not-so-important files, but you’d still like others not to access them easily. For important files like your financial documents, personal media, etc., use the BitLocker method. The BitLocker method is the most secure of all three. As long as you use a good password, it is almost impossible to access the contents of a BitLocker encrypted drive without proper authentication. While using BitLocker, don’t forget to backup the recovery key.

If you like this article, check how to enable Windows defender sandbox and how to enable Windows 10 sandbox to run applications in a sandboxed environment.

2 thoughts on “How to Lock Folder in Windows 10 & 11”

  1. Avatar for Geoff

    Great article thank you. I had been using the Batch file method and this stopped working so I just followed you instructions to create a new folder. Every time I try to lock the folder with “Y” and return, the folder just changes its name to:-
    Control Panel.{21EC2020-3AEA-1069-A2…

    Not sure why?

Leave a Comment

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

Scroll to Top