• Skip to main content
  • Skip to primary sidebar

Master Your Tech

Mobile phones, software, consumer electronic how-to guides

  • iPhone
  • Excel
  • Powerpoint
  • Word
  • Google Drive
  • Tech
  • Guides
You are here: Home / Guides / How to Lock a Folder in Windows 10: A Step-by-Step Guide

How to Lock a Folder in Windows 10: A Step-by-Step Guide

posted on March 16, 2026

How to Lock a Folder in Windows 10

If you’ve ever wondered how to keep your files safe from prying eyes, locking a folder in Windows 10 is a great solution. By using built-in tools, you can add a layer of security to your personal information. We’ll guide you through creating a locked folder with a password using a simple batch file. This method doesn’t require special software and is easy to set up.

Step-by-Step Tutorial to Lock a Folder in Windows 10

To lock a folder in Windows 10, you’ll create a batch file that enables you to password-protect a folder. Follow these steps to secure your files.

Step 1: Create a new folder

Right-click on your desktop, select "New," then choose "Folder."

Now, you have a new folder to store files you want to protect. Name it something memorable so you can easily find it later.

Step 2: Open Notepad

Search for "Notepad" in the Start menu and open it.

Notepad is a simple text editor that you’ll use to create a batch file. This file will help lock your folder.

Step 3: Copy and paste the batch file code

Paste the following code into Notepad:

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 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.
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%==YOUR_PASSWORD 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

Replace "YOUR_PASSWORD" with a password of your choice. This code creates a lockable folder named "Locker."

Step 4: Save the file as a batch file

Go to "File," then "Save As," and name it "FolderLocker.bat."

Make sure to save it with the ".bat" extension. This turns your text file into a batch file that Windows can execute.

Step 5: Run the batch file

Double-click the "FolderLocker.bat" file to create a "Locker" folder.

This step initializes your locker. You’ll store files in this folder, and it will be locked when you’re done.

Step 6: Lock the folder

Run the batch file again and follow the instructions to lock the folder.

Once the files are inside, the batch file will help you lock them securely behind your chosen password.

Step 7: Unlock the folder

Double-click the batch file, enter your password, and access your protected files.

Your folder is now hidden from view and will only be visible when unlocked with the correct password.

After you complete these actions, you’ll have a folder that’s hidden and password-protected. No one can access it without running the batch file and entering the password.

Tips for Locking a Folder in Windows 10

  • Ensure your password is strong and memorable to keep your files secure.
  • Keep a backup of your files elsewhere in case you forget the password.
  • Regularly update your password to enhance security.
  • Store the batch file in a safe location to prevent accidental deletion.
  • Consider using encryption software for highly sensitive information.

Frequently Asked Questions

Can I hide the batch file?

Yes, you can move it to a different location or rename it for extra security.

What if I forget my password?

Since the password is in plain text, you can recover it by checking the batch file. It’s wise to keep a copy of the password elsewhere.

Is this method completely secure?

While it’s a good deterrent, determined users may find ways around it. For top security, consider additional encryption.

Can I lock multiple folders this way?

This method is for a single folder. Create separate batch files for additional folders.

Why is my folder still visible after locking?

Ensure the locker folder is inside the same directory as the batch file. Check your code for errors if issues persist.

Summary

  1. Create a new folder.
  2. Open Notepad.
  3. Copy and paste the batch file code.
  4. Save as a batch file.
  5. Run the batch file.
  6. Lock the folder.
  7. Unlock the folder.

Conclusion

Locking a folder in Windows 10 is a straightforward way to protect your files. By following the steps outlined, you can create a secure folder that keeps your sensitive information away from prying eyes. While this method offers basic protection, always be mindful of potential vulnerabilities and consider additional security measures if necessary.

When it comes to safeguarding your digital life, a little effort can go a long way. That’s why taking the time to set up this simple batch file is worth it. It not only ensures your privacy but also gives you peace of mind knowing that your files are safe.

Feel free to explore more advanced options if you need extra protection. Remember, the digital world is vast, and being proactive is your best defense. If you found this guide helpful, share it with others who might benefit from learning how to lock a folder in Windows 10.

Matthew Burleigh
Matthew Burleigh

Matthew Burleigh has been a freelance writer since the early 2000s. You can find his writing all over the Web, where his content has collectively been read millions of times.

Matthew received his Master’s degree in Computer Science, then spent over a decade as an IT consultant for small businesses before focusing on writing and website creation.

The topics he covers for MasterYourTech.com include iPhones, Microsoft Office, and Google Apps.

You can read his full bio here.

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook

Related posts:

  • How to Lock Folder in Windows 11: Step-by-Step Security Guide
  • How to Lock a Folder in Windows: A Step-by-Step Guide
  • How to Lock a Folder on Windows 11: A Step-by-Step Guide
  • How to Lock a Folder in Windows 11: Secure Your Files Easily
  • Creating a New Folder on the Windows 11 Desktop: A Step-by-Step Guide
  • How to Find AppData Folder in Windows 11: A Step-by-Step Guide
  • How to Find AppData Folder in Windows 11: A Step-by-Step Guide
  • How to Password Protect a Folder in Windows: A Step-by-Step Guide
  • How to Access Shared Folder on Network Windows 10: A Step-by-Step Guide
  • How to Change Folder Icon in Windows 11: A Step-by-Step Guide
  • How to Zip a Folder on Windows 10: A Simple Step-by-Step Guide
  • How to Zip a Folder in Windows: A Step-by-Step Guide

Filed Under: Guides

Search

Primary Sidebar

Latest Posts

  • How to Turn Off PIN on Windows 11: A Step-by-Step Guide
  • How to Check IP Address on Windows: A Simple Step-by-Step Guide
  • How to Create a Network Drive in Windows 10: A Step-by-Step Guide
  • How to Do a System Restore on Windows 11: A Step-by-Step Guide
  • How to Open .7z Files on Windows: A Step-by-Step Guide
  • Contact Us
  • Privacy Policy
  • Terms and Conditions

Copyright © 2026 MasterYourTech.com