How to Lock Any Folder in Windows 11: A Step-by-Step Guide

Locking a folder in Windows 11 is a straightforward process that adds an extra layer of security to your files. By following a few simple steps, you can ensure that your private data remains protected from prying eyes. This guide will walk you through the process in detail, so you can lock your folders with confidence.

How to Lock Any Folder in Windows 11

In this guide, you’ll learn how to use a simple script to lock any folder on your Windows 11 system. This method involves creating a batch file that will both lock and unlock the folder using a password. Let’s dive in!

Step 1: Create a New Folder

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

To do this, right-click on your desktop or inside an existing folder, select "New," and then choose "Folder." Name it anything you like.

Step 2: Open Notepad

Open Notepad to write the script that will lock your folder.

Press the Windows key, type "Notepad," and hit Enter. This will open the Notepad application.

Step 3: Enter the Script

Copy and paste the following script into Notepad:

title Folder Locker
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
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 the password you want to use.

Step 4: Save the File

Save the Notepad file as "FolderLocker.bat" in the same location as the folder you created.

Select "File" > "Save As," choose "All Files" in the "Save as type" dropdown, and enter "FolderLocker.bat" as the filename.

Step 5: Run the Batch File

Double-click on the "FolderLocker.bat" file to run it.

This will create a folder named "Locker" in the same directory.

Step 6: Store Files in the Locker Folder

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

Simply drag and drop or copy and paste your files into the "Locker" folder.

Step 7: Lock the Folder

Run the "FolderLocker.bat" file again and follow the prompts to lock the folder.

Type ‘Y’ when prompted to lock the folder.

Step 8: Unlock the Folder

To unlock the folder, run "FolderLocker.bat" once more and enter your password when prompted.

The "Locker" folder will reappear with all your files intact.

After completing these steps, your folder will be locked and hidden from view. To access your files again, you’ll need to run the batch file and enter your password.

Tips for Locking Any Folder in Windows 11

  • Backup Important Data: Always keep a backup of important files before locking them in case something goes wrong.
  • Choose a Strong Password: Use a combination of letters, numbers, and symbols to create a strong password.
  • Do Not Share the Password: Keep the password confidential to ensure maximum security.
  • Rename the Batch File: For added security, rename the batch file to something inconspicuous.
  • Test the Script First: Try the script on dummy files to make sure it works correctly before using it on important data.

Frequently Asked Questions

Can I lock multiple folders using this method?

Yes, you can create multiple batch files for different folders.

What if I forget the password?

Unfortunately, you’ll lose access to the locked files unless you remember the password.

Is this method foolproof?

It’s relatively secure, but determined hackers may still find a way around it.

Can I use this method on older versions of Windows?

Yes, this batch file method works on Windows 7, 8, 10, and 11.

Will this method hide the folder from search results?

Yes, the folder will be hidden and won’t appear in search results.


  1. Create a New Folder
  2. Open Notepad
  3. Enter the Script
  4. Save the File
  5. Run the Batch File
  6. Store Files in the Locker Folder
  7. Lock the Folder
  8. Unlock the Folder


Locking a folder in Windows 11 is a simple yet effective way to add an extra layer of security to your personal files. By following the steps outlined in this guide, you can create a secure environment for your sensitive data. While the method using a batch file is quite secure, always remember to back up your important files and choose a strong password. If you ever run into any issues or have more questions, there are plenty of resources and forums online where you can seek additional help.

Securing your files is crucial in today’s digital age, so take the time to lock your folders and keep your data safe. For further reading, consider looking into advanced encryption tools and other security practices to complement the steps you’ve just learned. Stay safe and happy computing!