How to Lock a Folder Without Any Third-Party Software (Using a Simple Script)
Want to lock a folder on your Windows system without installing any third-party tools? In this guide, we’ll show you how to do it using a simple batch file. This is useful if you want to hide or protect files from casual access.
⚠️ This method offers basic protection only — it doesn’t encrypt your data. Advanced users can bypass it. For sensitive data, use proper encryption tools.
What You’ll Need:
- A Windows system (any version)
- Notepad
- Basic copy-paste skills
Steps to Create a Folder Lock Script:
1️⃣ Open Notepad
Copy and paste the following code:
bat
Copy
Edit
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 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 "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-Here 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
2️⃣ Replace Your-Password-Here
Find this line:
bat
Copy
Edit
if NOT %pass%==Your-Password-Here goto FAIL
Replace Your-Password-Here with your desired password. For example:
bat
Copy
Edit
if NOT %pass%==mypassword123 goto FAIL
3️⃣ Save the File
Click File > Save As
Save it with a .bat extension (e.g., locker.bat)
Set “Save as type” to All Files
4️⃣ Run the File
Double-click the locker.bat file.
A folder named Locker will be created.
Place your files inside the Locker folder.
5️⃣ Lock the Folder
Run the batch file again.
Type Y to lock it — the folder will disappear (hidden + system protected).
6️⃣ Unlock the Folder
Run the batch file again.
Enter your password to reveal the folder.
🔒 Important Notes:
Don’t forget your password — there's no recovery!
This script uses folder renaming and attribute hiding. It's not secure for sensitive data.
To view the folder manually, enable Show hidden/system files in File Explorer (not recommended for casual users).
⚠️ Disclaimer
Use this script at your own risk. It offers only basic folder hiding and is not secure against knowledgeable users. For true protection, consider using professional encryption tools. We are not responsible for any data loss or misuse.