If you want to protect your personal files without installing any software, you can create a password-protected folder using a simple BAT file in Windows.
This trick uses CMD commands and works on both Windows 10 and Windows 11.
Follow this step-by-step guide carefully.
📌 What Does This Trick Do?
This BAT file will:
Create a hidden folder
Lock the folder with password
Hide files from normal users
Unlock folder using password
No third-party software is required.
⚠️ Important Note
This is a basic folder protection trick for personal use.
✔️ Good for:
Hiding private files
Basic protection
❌ Not recommended for:
Highly sensitive data
Professional security needs
💻 Step 1: Open Notepad
Press Windows Key
Search for:
Notepad
Open it
🧩 Step 2: Paste the BAT Script
Copy and paste the code below into Notepad:
@echo off
title Folder Locker
color 0A
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
if NOT EXIST Locker goto MDLOCKER
:CONFIRM
echo.
echo Are you sure you want to lock the folder? (Y/N)
set /p cho=
if /I "%cho%"=="Y" goto LOCK
if /I "%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.
echo Folder Locked Successfully!
pause
goto END
:UNLOCK
echo.
echo Enter password to unlock folder:
set /p pass=
if NOT "%pass%"=="1234" goto FAIL
attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" Locker
echo.
echo Folder Unlocked Successfully!
pause
goto END
:FAIL
echo.
echo Invalid Password!
pause
goto END
:MDLOCKER
md Locker
echo.
echo Locker folder created successfully!
pause
goto END
:END
exit
💾 Step 3: Save as BAT File
Click File → Save As
File name:
locker.bat
Select:
Save as type: All Files
Click Save
▶️ Step 4: Run the BAT File
Double-click
locker.batA folder named:
Locker
will be created.
Put your files inside the folder.
🔒 Step 5: Lock the Folder
Run
locker.batagainPress:
Y
Folder will become hidden and locked.
🔓 Step 6: Unlock the Folder
Run
locker.batEnter password:
1234
Folder will unlock successfully.
⚙️ How to Change Password
Find this line:
if NOT "%pass%"=="1234" goto FAIL
Replace:
1234
with your own password.
Example:
if NOT "%pass%"=="mypassword" goto FAIL
🚀 Benefits of This Trick
No software required
Easy to use
Lightweight
Works offline
Beginner-friendly
⚠️ Important Tips
Remember your password
Keep BAT file safe
Do not delete the BAT file
Use stronger password for better security
📝 Final Words
Using CMD and BAT files to lock folders is a simple and fun Windows trick for protecting personal files. It is lightweight, easy to create, and works without extra software.
For better security, always use a strong password and keep backups of important data.
For more Windows tricks and coding guides, visit CodeSardar.
❓ Frequently Asked Questions
Q1. Is this method completely secure?
It provides basic protection but is not military-grade security.
Q2. Can I change the password?
Yes, edit the BAT file and replace the default password.
Q3. Does it work on Windows 11?
Yes, it works on both Windows 10 and Windows 11.
