How to Lock a File in Windows 10
Keep your PC files secured with a password using a built-in Windows method — no additional software required.
There are many ways to keep files secured. While cloud storage services offer access from anywhere, and portable devices like pen drives and hard drives offer portability, sometimes you need local encryption on your own machine.
Password-Protect Files Without Any Software#
Windows 10/8/7 has a built-in method to encrypt files and folders using a pre-defined .bat script — no third-party software needed.
Here’s how it works:
Step 1: Create a Locker Folder#
Open Notepad and paste the following script:
cls@ECHO OFFtitle Folder Lockerif EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCKif NOT EXIST Locker goto MDLOCKER:CONFIRMecho Are you sure you want to lock the folder(Y/N)set/p "cho=>"if %cho%==Y goto LOCKif %cho%==y goto LOCKif %cho%==n goto ENDif %cho%==N goto ENDecho Invalid choice.goto CONFIRM:LOCKren Locker "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"echo Folder lockedgoto End:UNLOCKecho Enter password to unlock folderset/p "pass=>"if NOT %pass%== YOUR_PASSWORD_HERE goto FAILattrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" Lockerecho Folder Unlocked successfullygoto End:FAILecho Invalid passwordgoto end:MDLOCKERmd Lockerecho Locker created successfullygoto End:EndStep 2: Set Your Password#
Replace YOUR_PASSWORD_HERE in the script with your desired password.
Step 3: Save as a .bat File#
Save the file as locker.bat (select All Files in the file type dropdown so it doesn’t save as .txt).
Step 4: Run and Lock#
Double-click locker.bat to create the Locker folder. Move your files into it, then run the script again and type Y to lock. The folder will become hidden and password-protected.
Step 5: Unlock#
Run the script again, enter your password, and the folder is restored.
Important Notes#
- This method hides the folder using a system trick, not encryption. It’s suitable for basic privacy on a personal PC.
- For stronger security, consider BitLocker (built into Windows Pro/Enterprise) or VeraCrypt for true encryption.
- Always keep a backup of your password — there’s no recovery option with this method.