In an earlier post I had written about how to create an invisible folder. That’s a method to create a merely invisible folder with no real protection.
Now, here we will see how to create a folder that will not just be invisible, but also require a password to reveal it and open it. The best part is that you don’t need any special software to do this. Just plain old Notepad is all that you need.
Here is the code that you need:
cls
@ECHO OFF
title Folder Personal
if EXIST “Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}” goto UNLOCK
if NOT EXIST Personal 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 Personal “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%==pwd123 HERE goto FAIL
attrib -h -s “Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}”
ren “Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}” Personal
echo Folder Unlocked successfully
goto End
:FAIL
echo Invalid password
goto end
:MDLOCKER
md Personal
echo Personal created successfully
goto End
:End
Now here is what you need to do:
Just copy the above code and paste it into Notepad. Save it by giving it any name you choose. Assuming, the file is called secret.txt, change the extension to ‘.bat‘ so that the new name becomes secret.bat. What you get is a batch file. You could actually save one step by saving the file in Notepad directly as secret.bat by enclosing the file name like this: “secret.bat” . This batch file is the one that you need. You can edit this batch file to change the folder name and the password. To change the name of the folder that is created, change the ‘Personal’ (in bold in the above code) to any another name you choose. Likewise change the ‘pwd123′ (in red in the code) to anything else.
Now let’s see how to use it. Place the file in the location where you would like to create your protected folder. Run the batch file by double clicking on it. This will create a folder named Personal in the same location as the batch file. You can now open this folder and place any files in it. Once you are finished, run the batch file again. You will be asked whether you want to lock the folder. Entry ‘Y’ (for Yes) and hit Enter. The folder becomes invisible. To retrieve the folder, run the batch file again. You will be prompted to enter the password. Enter the password, hit enter and voila! the folder appears.
Important: The batch file acts like a key to open the locked folder. So once you have created and locked a folder, do not keep the batch file in the same location since anybody can open the batch file and view your password. So I would suggest that you keep the batch file in a separate and safe place or better still keep it on your pen drive or flash drive. That way when you want to open the folder just copy the batch file to the location where you have your protected folder and run it.
Do remember that the above method is not intended to act as a substitute for the numerous free and commercial softwares that are specifically designed to provide security and encryption to your data.
Update: I got comments saying the code does not work. Of course I did check it before posting it here. But I have identified the problem. The problem is with the straight double quotes used in the code in this post. Once you copy the code you would also need to change each of the double quotes with your keyboard double quotes. That might seem a lot of work for some. So I thought it would be easier to give away the batch file itself. You can download the file here. (Use right-click and ‘Save Target as’ or ‘Save Link as’).
If you're new here, you may want to subscribe to my RSS feed or get updates through email. Thanks for visiting!












January 12th, 2008 at 1:47 pm
Doesn’t work(In XP).The folder does get created,but doesn’t get locked or anything.
January 12th, 2008 at 2:45 pm
@SB: Maybe you are missing some step. I have tried it myself and it works in XP. Once the folder is created you need to run the batch file again to lock the folder. In fact the folder will become invisible.
January 12th, 2008 at 2:54 pm
Well…it doesn’t.Upon running the batch file again,it does ask for confirmation,but neither Y nor N do anything at all.Besides which,another file of unknown format is created when the batch file is run the second time.
January 12th, 2008 at 11:21 pm
looks like a big task. Make it into a software… You could give it away for free in this website..
January 12th, 2008 at 11:23 pm
It seems like I am an aussie…
January 13th, 2008 at 8:22 am
@Niyaz: Well, if I make it into a software, I would have to change the title of the post too.
Anyway, will surely post it, if I come up with something.
January 13th, 2008 at 2:14 pm
Still doesn’t work..
January 14th, 2008 at 6:43 am
@Niyaz: It IS strange that the flag beside your name suggest you are an Aussie
. But somehow according to ARIN WHOIS, your IP shows up as Australian. Check this link out http://ws.arin.net/whois/?queryinput=117.97.50.191
January 18th, 2008 at 4:47 pm
hi it nise.But the folder open with any key
without password)in WINXP.
regards
mkumar
January 20th, 2008 at 10:37 pm
hey it worked in my xp~~~thanx mate~~
January 21st, 2008 at 4:27 pm
doesn’ work if you use Xnview (or any type of image manager, you can still see the content of the folder)
January 27th, 2008 at 6:35 pm
It hides the folder ,requist for a password but any password typed makes the file visible
January 31st, 2008 at 6:56 pm
Hey…
its in not woking PWD step….
it is taking any password…..
please try to make the folder visible after locking.
January 31st, 2008 at 8:45 pm
@Everybody: Sorry, there was a slight error in the code due to which the folder became visible for anything entered as password. I have corrected the code and now it is working. Pls download the secret.bat afresh from the link at the bottom of the post.
February 2nd, 2008 at 3:33 pm
very nice trick
February 3rd, 2008 at 5:22 pm
hi boss its working. thanks for your efforts.
February 7th, 2008 at 12:21 am
I got it to work and the file is hidden but now I can’t unlock it, it is not taking my password.
February 11th, 2008 at 9:50 am
hi, how can make it password protected also in network?
’cause whenever i tried unlocking it.. it comes up to be visible also in the network.. that means anyone from my network can access that folder.. thanks.
February 12th, 2008 at 2:51 am
I tried many times! But it didn’t work! I can create the Batch File and then also create a Batch folder by “Double Clicking on the Batch File” but after i move my documents inside the Batch folder, thats why the problem happen! I am suppose to run the Batch File again to lock it RIGHT! Well….A window did pop up asking me if i want to lock the Folder after running the Batch FILE again, I then entered “Y” (yes) to lock it the window disappears…. LOL nothing happened! The folder didn’t become invisible and i can simply click on the folder again to access it!
March 3rd, 2008 at 12:02 pm
iT’S WORKING, BUT I WANT NOT TO HIDE THE FOLDER IT SHOULD BE VISIBLE, BUT WHEN I DOUBLE CLICK THE FOLDER OR OPEN OR EXXPLORE THEN IT SHOULD DEMAND FOR PASSWORD.
March 3rd, 2008 at 3:53 pm
@Vikrant: I don’t know if you can achieve that without using a software. But if you have a compression utility like Winzip or Winrar installed then you can zip the folder and while doing so use a password to protect it. That way the contents of your folder would be protected. Just a workaround.
March 21st, 2008 at 11:18 am
Hey,
Thats really a nice program
Thanks for that
Good Day
April 23rd, 2008 at 2:46 am
i downloaded the batch file and i dont know the password
April 24th, 2008 at 4:35 am
dude people can just right click, edit, and see the pass word.
how can u prevent this?
also what do i type so if you fail the password it loggs you off?
April 24th, 2008 at 5:43 am
@Mike: You are right. People can see your pwd if they can see your batch file. That’s precisely the point I am trying to make in the Important: section of the post.
April 25th, 2008 at 2:14 am
use this code its better:
cls
@ECHO OFF
title lock
if EXIST “Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}” goto UNLOCK
if NOT EXIST lock goto MDLOCKER
:CONFIRM
echo Are you sure u want to Lock the lock(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 lock “Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}”
attrib +h +s “Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}”
echo lock locked
goto End
:UNLOCK
echo put in the key to Unlock the lock
set/p “pass=>”
if NOT %pass%==??? goto FAIL
attrib -h -s “Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}”
ren “Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}” LOCK
echo lock Unlocked
goto End
:FAIL
echo Invalid keyword
goto end
:MDLOCKER
md LOCK
echo lock unlocked
goto End
:End
April 25th, 2008 at 2:19 am
then change icon to a locker lock then make a folder called keys then change icon to keys and keys holds a txt. doc. with your password in it
April 25th, 2008 at 2:21 am
then name the batch file to: open and close the lock
April 25th, 2008 at 7:45 pm
mike says:
April 24th, 2008 at 4:35 am
dude people can just right click, edit, and see the pass word.
how can u prevent this?
also what do i type so if you fail the password it loggs you off?
Answer:
Hi,
Do one thing drop the batch file into WINZIP or WINRAR with password protected then anybody cannot open batch file and cannot see your password.
April 26th, 2008 at 11:41 pm
@Mike: You are right. People can see your pwd if they can see your batch file. That’s precisely the point I am trying to make in the Important: section of the post
Then whats the point of this whole thing?
April 27th, 2008 at 5:16 am
WHERE IS THE HIDDEN FOLDER GO WHEN LOCKED?
May 14th, 2008 at 6:19 pm
Hi
this is working great…but i have a query …..suppose i have forgot the password so how can i retrieve that
May 21st, 2008 at 8:54 am
Ok I did this. Worked at first, but now when I click on the .bat an empty folder comes up! Where did my files go? Is there any way to retrieve them?!
May 29th, 2008 at 6:58 am
right click the batch file and click edit
June 2nd, 2008 at 6:46 am
excellent work dude
June 10th, 2008 at 5:18 am
vj says:
excellent work dude
me?
June 14th, 2008 at 9:51 am
please how create a folder with protected password
June 16th, 2008 at 9:54 pm
great work man… i have to develop like this only… thanks..