Skip to content
KD
Go back

How to Lock a File in Windows 10

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 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_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

Step 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


Share this post on:

Previous Post
Mastering Cloud Computing
Next Post
Nano Editor Keyboard Shortcuts — Complete Reference