How to protect a Folder with password in Windows PC/laptop

Secure your folder with password without using any additional software in your Windows 7/8.1/10 PC/laptop

This article will be helpful for those who want a better level of privacy than the level offered by basic OS functionalities. And also do not want to struggle with various software available as free or paid.

In this article we will teach you to password protect a folder(and transfer your private stuff in it) just by using command prompt.

Okay, first of all you need a text editor(notepad will do), and you have to copy the following code there. Replace “YourPassword” with the password you want to give to the folder (without double quotes).

cls
@echo off
echo www.techworm.net
title Folder Private
if EXIST TWlock 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 %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 Private TWlock
attrib +h +s TWlock
echo Folder locked
goto End
:UNLOCK
echo Enter password to unlock folder
set/p “pass=>”
if %pass%==YourPassword goto Decrypt
goto FAIL
:Decrypt
attrib -h -s TWlock
ren TWlock Private
echo Folder Unlocked successfully
goto End
:FAIL
echo Invalid password
goto End
:MDLOCKER
md Private
echo Private created successfully
goto End
:End

Now save the file as a .bat file(give any name you want, I have given name “Cipher”).

Third step is to open this file. ( I recommend that you open this batch file by command prompt rather than by clicking on it, in this way you will be able to see all the action)
How to protect a Folder with password in Windows PC/laptop
As you open the file for the first time, it creates a folder named “Private” in the same directory as of the batch file.
How to protect a Folder with password in Windows PC/laptop
You can place your desired stuff in this folder.
Now again open Cipher.bat in cmd and you will be presented with a choice of yes or no. Once you type ‘Y’ the folder will be locked.
How to protect a Folder with password in Windows PC/laptop
After this the folder will be locked.
How to protect a Folder with password in Windows PC/laptop
Whenever you need access,open Cipher.bat again, Enter the required password and the folder will be unlocked.
How to protect a Folder with password in Windows PC/laptop
This is it! You are ready to go. And if you face any problem or have any doubt, comment below and we will resolve asap.

Abhishek Awasthi
Abhishek Awasthi
Continuous improvement is better than delayed perfection -Mark Twain.

19 COMMENTS

  1. hello dear,
    i try it step by step but at the last
    when i want to lock folder after
    yes.
    below statement is given :
    (go to was unexpected at this time).
    dont know wht to do after this

  2. I don’t know much about batch programming but I managed to fix it for myself. So for people getting the (go to was unexpected at this time) error change this line set/p “cho=>” to this set /p cho=”>” and this set/p “pass=>” to this set/p pass=”>” it should work after those changes. Also too bad the password isn’t hashed and only plain text passwords are compared. The only thing someone has to do to find the password is right click your batch file, click edit and find the line where the hard-coded password is being compared with the input.

  3. This doesn’t “lock” the folder it just hides it. And if you have option “Show hidden files” turned on you can still see blurred folder (hidden)

  4. will u pls describe me this coding.
    i want to know what the meaning of every code so that i can easily learn this to teach other. pls email me. pls

  5. IT IS THE WAY TO HIDE FOLDER AS SYSTEM PROTECTED WAY….
    WE CAN STILL ACCESS FILES USING ITS PATH IN THAT FOLDER NAMED TWLOCK….
    Please give some real locking tips…. 🙂

  6. Love that it’s just a hidden system folder that’s renamed, and password can be extracted by simply viewing the bat file. To fix the password issue, kinda, you should be able to use a vbs file that references the batch file, and that way it’s not in the same file, though obviously still easy to find. Be better off if you quickly create a .exe file using Visual basic or something, but still have the problem of it just being s hidden system file.

  7. Simplest way is to create the folder, put your stuff in it, and using either 7zip or winrar, (after installing them) right-click the folder and create a 7z/zip file of it that’s password protected, and delete the original folder. When you want to open it, unzip it with the password. Simple, secure, no clear text password in a .bat file that anyone can access. 7zip has extremely good encryption abilities, and is free as well, so that’s your best bet.

  8. My friend. If someone wants to find the hidden file. He can edit the batch file and see the password. So tell me how to protect that batch file from theft.?

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Read More

Suggested Post