How to Lock a Folder on Windows 11: Step-by-Step Guide to Secure Files

How to Lock a Folder on Windows 11

Locking a folder on Windows 11 is a handy way to keep your personal files safe from prying eyes. The process involves creating a password-protected folder without needing any third-party software. Just follow the steps below to create a secure folder you can trust.

Locking a folder on Windows 11 involves creating a special file that will prompt for a password to unlock access. This method is straightforward and ensures your important files are protected.

Step 1: Create a New Folder

First, create a new folder where you want to store your files.

Right-click on your desktop or desired location, then select "New" > "Folder." Give it an appropriate name.

Step 2: Open Notepad

Next, open Notepad.

You can do this by typing "Notepad" in the Start Menu search bar and clicking on the Notepad app.

Step 3: Create a Lock File

Copy and paste a specific script into Notepad.

Use this script, adjusting the password section:

title Folder Locker 
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK 
if NOT EXIST Locker goto MDLOCKER 
echo Are you sure you 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. 
ren Locker "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 folder 
set/p "pass=>" 
if NOT %pass%==YOURPASSWORD goto FAIL 
attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" 
ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" Locker 
echo Folder Unlocked 
goto End 
echo Invalid password 
goto end 
md Locker 
echo Locker created successfully 
goto End 

Replace "YOURPASSWORD" with your desired password.

Step 4: Save the Script

Save the Notepad file with a ".bat" extension.

Go to "File" > "Save As," select "All Files" from the Save as type dropdown, and name it "FolderLocker.bat."

Step 5: Run the Batch File

Double-click the "FolderLocker.bat" file.

This will create a new folder named "Locker" in the same location as your batch file.

Step 6: Store Your Files

Move the files you want to protect into the "Locker" folder.

You can drag and drop your files into this folder just like any other.

Step 7: Lock the Folder

Double-click the "FolderLocker.bat" file again, then follow the on-screen prompts to lock the folder.

When prompted, type "Y" and press Enter. The folder will disappear, becoming hidden and locked.

Step 8: Unlock the Folder

To unlock, double-click "FolderLocker.bat" and enter your password.

Your folder will reappear, and you can access your files.

After completing these steps, your folder will be securely locked and hidden. You’ll need to enter the correct password to unlock and view its contents.

Tips for Locking a Folder on Windows 11

  • Make sure to remember your password. If you forget it, accessing your files could be difficult.
  • Customize the batch script with your own folder names and passwords for added security.
  • Test the process with non-critical files first to ensure it works correctly.
  • Create a backup of important files before locking them, just in case something goes wrong.
  • Use strong, unpredictable passwords to enhance security.

Frequently Asked Questions

How do I change my password?

To change your password, edit the .bat file with Notepad and replace "YOURPASSWORD" with your new desired password.

How do I make the folder visible again?

Run the .bat file and enter the correct password. The folder will become visible and accessible.

Can I lock multiple folders this way?

Yes, but you’ll need to create separate batch files for each folder you want to lock.

What if I forget my password?

If you forget your password, you may need to use recovery software or seek professional help to regain access to your files.

Can others see the locked folder?

The folder will be hidden from view in File Explorer, adding an extra layer of security.


  1. Create a new folder.
  2. Open Notepad.
  3. Create a lock file.
  4. Save the script as a .bat file.
  5. Run the batch file.
  6. Store your files in the "Locker" folder.
  7. Lock the folder.
  8. Unlock with your password.


Locking a folder on Windows 11 is a simple yet effective way to protect your private files. By following the steps outlined above, you can ensure that your personal data remains secure from unauthorized access. Remember, the key to maintaining this security is a strong, memorable password and a little bit of caution. If you’re serious about keeping your files safe, it’s worth the effort to master this straightforward method.

For further reading, explore other security features Windows 11 offers, such as BitLocker and Windows Hello. Keeping up with these tools can provide an all-around safer computing experience.

Lock your folders with confidence, and keep your files as safe as Fort Knox!

Get Our Free Newsletter

How-to guides and tech deals

You may opt out at any time.
Read our Privacy Policy