Create a Password Protected Folder in Windows

x32x01
  • by x32x01 ||
If you share a PC with family, roommates, or coworkers and want a quick way to hide personal files, a simple password-protected folder trick using a .bat file can help. This method doesn’t offer strong cryptographic security, but it’s fast and useful for casual privacy - and I’ll show safer alternatives below if you need real protection. 💡

How this trick works (simple overview) 🧠

The technique uses a Windows batch script that creates a folder called Private and then renames it to a special Control Panel shell name to hide it. Running the same .bat file again prompts for a password and, if entered correctly, renames the hidden object back to a normal folder so you can access your files.

Important: The password is stored in the batch file as plain text. That means anyone who can open the .bat file can read the password. Treat this as convenience privacy, not true security. ⚠️

The BAT file: step-by-step and code 🛠️

  1. Pick the folder where you want the script (choose a location others don’t often browse - e.g., C:\Tools or a deep subfolder).
  2. Open Notepad and paste the code below.
  3. Replace your_password_here with your chosen password (8+ characters recommended).
  4. Save the file as locker.bat (make sure the extension is .bat, not .txt).
  5. Double-click locker.bat to create the Private folder, put files inside, then run locker.bat again to lock.
Bash:
@ECHO OFF
title Folder Locker
:: Change the password between the quotes below:
set "PASS=your_password_here"

if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
if NOT EXIST Private goto MDLOCKER

:CONFIRM
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 Private "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%"=="%PASS%" goto FAIL
attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" Private
echo Folder unlocked successfully.
goto End

:FAIL
echo Invalid password.
goto End

:MDLOCKER
md Private
echo Private folder created successfully.
goto End

:End



How to use the script (quick workflow) ▶️

  • Create: Double-click locker.bat the first time → it creates a folder called Private.
  • Store: Put any files you want to hide inside Private.
  • Lock: Double-click locker.bat → confirm Y → the folder disappears (hidden).
  • Unlock: Double-click locker.bat → enter password → folder reappears.



Recovery & troubleshooting 🔎

  • Forgot your password? Right-click the .bat file → Edit to view the password in plain text (that’s why it’s insecure).
  • Can’t delete or see the folder? Go to File Explorer > View > Options > Change folder and search options, then show hidden files and uncheck “Hide protected operating system files.”
  • If the script won’t run: Right-click the file and choose Run as administrator, or check that .bat files are allowed by your antivirus (some tools block unknown scripts).
  • Stop a running script: Open Task Manager (Ctrl+Shift+Esc) and end cmd.exe, wscript.exe, or the relevant script process if necessary.



Why this method is limited - and the risks ⚠️

  • Password is stored in plain text inside the .bat file - any user who can edit it can read your password.
  • Not encrypted: files are merely hidden, not protected with crypto. A knowledgeable user can easily reveal or copy the files.
  • Antivirus or corporate policies may flag or block .bat scripts.
  • Not suitable for sensitive data (banking info, IDs, legal contracts, etc.).

If you need real confidentiality or must comply with privacy rules, use one of the stronger options below.



Safer alternatives (recommended for real security) ✅

If your files are sensitive, use one of these options instead of a batch hide trick:

BitLocker (built-in, full-disk or drive encryption) 🔐

  • Best for encrypting entire drives or removable USB sticks (Windows Pro/Enterprise).
  • Provides strong encryption (AES) and integrates with Windows login.

VeraCrypt (free, open-source encryption) 🛡️

  • Create an encrypted container (file-backed volume) that mounts like a virtual drive.
  • Strong AES/Tiger/Serpent encryption and cross-platform compatibility.

7-Zip AES-256 Archive (easy file-level encryption) 📦

  • Right-click files → 7-Zip → Add to archive → select AES-256 and a password.
  • Great for sharing or archiving encrypted files.

NTFS permissions (access control) 👥

  • Right-click folder → Properties → Security tab → restrict which Windows accounts can read or write.
  • Not encryption, but effective in multi-user PC environments where each user has a separate Windows account.



Best practices & tips 🔐💡

  • Use long, unique passwords (12+ characters) for real security.
  • Keep backups of important files in a secure location (external encrypted drive or cloud backup).
  • If using a .bat method, store the .bat file somewhere obscure and do not share it. Still, assume it’s discoverable.
  • Prefer VeraCrypt or BitLocker when handling financial, legal, or personally identifiable data.
  • If you must hide files quickly for casual privacy, remember this method is a convenience hack - not a security guarantee.



Final thoughts ✅

The .bat locker is a handy, zero-install trick for quick & casual hiding of files on a shared Windows machine. But it’s not secure - passwords live in plain text and files are only hidden, not encrypted. For genuine privacy and compliance, use BitLocker, VeraCrypt, or encrypted 7-Zip archives.

If you want, I can:
  • Produce a VeraCrypt step-by-step guide (with screenshots), or
  • Create a one-page cheat sheet comparing BitLocker vs. VeraCrypt vs. 7-Zip, or
  • Help you automate encrypted backups of your Private folder.
Which option would you like next? 🔁
 
Last edited:
Related Threads
x32x01
Replies
0
Views
787
x32x01
x32x01
x32x01
Replies
0
Views
831
x32x01
x32x01
x32x01
Replies
0
Views
943
x32x01
x32x01
x32x01
Replies
0
Views
788
x32x01
x32x01
x32x01
Replies
0
Views
799
x32x01
x32x01
x32x01
Replies
0
Views
793
x32x01
x32x01
x32x01
Replies
0
Views
807
x32x01
x32x01
x32x01
Replies
0
Views
816
x32x01
x32x01
x32x01
Replies
0
Views
755
x32x01
x32x01
x32x01
Replies
0
Views
1K
x32x01
x32x01
Register & Login Faster
Forgot your password?
Forum Statistics
Threads
629
Messages
634
Members
64
Latest Member
alialguelmi
Back
Top