Create a password protected folder without any special software

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.

Note: This is NOT a very secure method of protecting your folders. So use it at your own risk.

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’).

Comments

  1. Mrittik says

    how to assign the password
    after i hit y in the batch file it becomes invisible
    after that when i again run the batch file i am prompted to enter the password while i have not yet assigned the password
    hoe to assign it
    Help Me

  2. John-doe says

    thanks! this is brilliant, was trying to fix the first problem for ages, then once i realised it was to do with the quotes and fixed it I came back on here to see the next part, and then i saw the update telling me so! :) another update worth adding in is that passwords that have spaces in them do not work.

  3. al quitoi says

    I used this method and I have a key that makes the file in visible by using a password. However the files are visible when you search files. What is wrong.?

  4. JP says

    This is just what I’ve been looking for – almost.
    I need to make it uneditable so the password can’t be seen – I’ve tried the EXE file but get an error message saying the CPU has encounted an illegal instruction and closes.

    Any advice

  5. says

    Thanks for your post! It helped me much when I wanted to create the protected folder on about 100 PCs in our office. I just want to tell you that it is handier to convert this BAT file to EXE, I did it with help of Dr.Batcher ( http://www.drbatchet.com ). Also this tool is useful to create batch files in general.

  6. Rexzu says

    You dont have to copy the bat file to another location if you convert the bat file into exe file. Than noone can see your password, but only minus is that you cant change your pass and/or folder name anymore.

  7. harral says

    I figure out the problem in the code which allow any password to appear the folder………………
    just del the HERE in front of pwd123 (inred colour).
    enjoyeeeeee….

  8. TNT2898 says

    I set this up yesterday with all the fixes and was able to use it with no problem. Today when we opened it and altered the files inside now we cannot lock and hide the folder. When it shows the locking screen and we put “y” in to lock it it gives the response “access denied”. Please if anyone knows how to fix this it would be a great help.

  9. Tanvi says

    Hey thanx fr the code..but i’ve a problem…
    i tried locking two folders at the same place ..the 1st one was locked then i tried locking the 2nd one but nothing happened after the prompt .. “Are you sure u want to Lock the folder(Y/N)..”
    & then when i tried to unlock my 1st folder it didn’t appear instead a new folder was created… so is there any way to recover my 1st folder again????
    Please help me…
    hope to get an early reply…

  10. James says

    Hi i have a folder lock and i forget the password. i went to the MS-DOS and when i finally find the folder i found these ” [DIR] com1.{d3e34b21-9d75-101a-8c3d-00aa001a1652}” but i can not access with “cd com1.{d3e34b21-9d75-101a-8c3d-00aa001a1652}” when i put only “com1.{d3e34b21-9d75-101a-8c3d-00aa001a1652}” it say “access denied” and i also find a file called “desktop.ini” and i find this inside the file “[.ShellClassInfo]
    CLSID={2227a280-3aea-1069-a2de-08002b30309d}” can someone help me plaese to open mi protected file is verry important PLEASE

  11. jaydeep says

    hi sir, this is amazing code to lock the any folder
    but there is some prblm that is we can give any psw and file can be visible .

  12. rachit says

    hello,
    my problem is “what if anyone delete the batch file from the system
    then how to retrieve the data that was hidden if i didn’t have acess to – internet at that particular time and i need the data urgently?”

  13. rohit says

    i tried this code to lock a folder it’s creating a folder but not making it invisible and not locking it after prompting (Y/N)….
    could you please help me for this

  14. Souless says

    This is not really a BIG safe gaurd. Someone can just right click and edit. And BAM! they see your password right next to the password coding. And this wont protect you from everyone but only those who dont know squat about computers.

    • madshark says

      may be there are other processed that handle the file in the folder..use unlocker to free the folder from other processed

  15. hylim says

    the password can see, if anyone know when type the password become *****, so somebody don’t know the password we key in.

  16. says

    hi
    when i run the batch folder it will appear the private folder.then when i put my data in private folder and i run the batch file again the folder will not become invinsiable.
    plz help

  17. Georges says

    hi pls can anyone explain how to set exactly a password because it’s right all what i wrote as password open the folder and if i delete the word “HERE” in this line
    if NOT %pass%==pwd123 HERE goto FAIL

    the code become not working…

    so plz help how to set correctly a password ????

    • madshark says

      well then..this is my code


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

  18. satyagya says

    i had made a folder in my “E” drive and i had to format my “c” drive now the icon for link to control panel is missing, please advice how to locate the foder link.

  19. satyagya says

    my problem is that i had to format my “c” drive and as hiden folder is shown as a link of control pannel, though i had made the hiden folder in anothr drive, now the link is not visiable. Can i still get my data back. How to access the same.

  20. Selam.S says

    Thank you, I have been looking ways to do this for a long time.
    It really works, well I had to change the double quotes to the one on my key board.
    Awesome

  21. Rathi says

    It have one problem. It accept all password. i give the pw was test. After that i give the wrong pw rathi. That also accepted. Then how is it protect?

    • madshark says

      the problem is within this line

      if NOT %pass%==pwd123 HERE goto FAIL

      delete ‘HERE’

      it will not accept any password except the real one..
      these codes sure helps a lot..thanks for sharing..cause sharing is caring..

  22. Alicks says

    hey its not working in my PC …i have install xp sp2…. i have save this file as .bat but when i have open it i will close automatically….can u send me real trick plz its urgent ……my id is alicksgohil@gmail.com ……….Thank You

  23. tata says

    this is bullshit , when entering a password , u can write any password and the folder will be shown , u can even write asjkdasdhjkashdjkh as a password and the file will be shown.

  24. Person Who Needs Help says

    Ok…I have a brandnew computer, its one step down from the touch screen one. Its an HP Vista and these codes arent working correctly.

    I did everything up to the point where you type in “Y”
    When I type in Y, it does nothing….

    So Im at the point where I have files in the folder, but It wont become invisible, or lock, or ask for a password. This seems to be happining with all the websites Ive been on.

    • ram says

      read it word by word
      u will get it
      Once you copy the code you would also need to change each of the double quotes with your keyboard double quotes.

  25. deepakhnair says

    Oops! Whatever it may be, this script will work or not, it wouldn’t give you any security as you desire for your folder. Assume that the script works fine and your folder got locked. Just go to folder options and select “Show hidden files and folders” and unchecked are “Hide extensions for known file types” and “Hide protected operating system files”. Now you can see your locked folder as a control panel icon which is faded in color and it works as control panel as well, when clicked. All you need is to rename it into something and you can go inside that folder!!! This is because all your script does is nothing but it makes your folder as hidden system folder and change the CLSID to exactly that of Control Panel!! So removing the folder properties and CLSID will work reverse without any need of password. Password is given only for the script to work. And if we need a password, one which sees your script, can also see your password as well.

  26. yogendra singh shekhawat says

    But after all of these things one can easily access the file
    exist in this folder by MS-DOS

    >> dir (go to the drive where it is,you can see the name of folder by “dir”)
    >> cd Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}
    >> dir (it will show the list of folders n files)
    >> copy (copy your desirable file to anywhere in pc from where you can access it)

  27. sasitha says

    Plz help! i created everything alright! but something went wrong. now i cant open the hidden folder. I enterd the password. but i the folder doest get opened up. the place where i have stored the key is a separate folder named test1. when i click on properties and check the capacity it shows that the files are there. But i cant open the folder when i enter the password after double clicking the key. why is this?? plz help

  28. EMWrunr says

    umm this is super easy to break just edit the batch file’s pwd and bam you have the file. is there anyway to make it so that if you change it, it doesnt change the password the folder is saved under?

  29. says

    floder is created but folder cannot lock some one of the file is save at the folder place when bouble click the bit file some other file is save and folder cannot be locked or invisible. I dowdload bat file but i cannot get notepad file so that i can chance folder name and password to folder.please send me feed back or note pad of scripting

  30. REYNAN says

    Thanks ma’am! Its a good Code. I used it and it works just fine. But its only good for non-techies, geeks can still unhide it and view your files if they want to…

  31. Bharath says

    good 1 bro… :)
    small tip for people who wan2 see the hidden folder…
    click on
    tools>>folder options
    select view tab..
    scroll down, click show hidden files & folders..
    then uncheck the row saying
    hide protected OS files…(select “yes” wen prompted)
    now in the place u hav ur personal hidden folder (i.e the
    control panel shortcut)….
    select the file & rename it to wat ever u want…

    there u r…
    all ur files will b shown….
    enjoy…!!

  32. Alex says

    i did it and im no computer wiz and it works fine i actually think its really great and i will use it at school so they cant find my games :P thnx man i will hav to show this to evry1

  33. man says

    dude if i renamethe Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D} folder to any other then the security is gone?

    need something more to this to make it use ful.

  34. cooldude says

    dude this is a better way. i just modified the program so that instead when u get the pass wrong then it will ask for the pass again so on so forth. i give credit to mike though. here it is. I changed the names
    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(P/S)
    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 UNLOCK
    :MDLOCKER
    md LOCK
    echo lock unlocked
    goto End
    :End

  35. James says

    please help me..after locking the folder and unlocking it, i cannot view the whole folder anymore..please..please..please…they are all important files!!!

  36. Abhishek says

    This code is very nicely made and the programmer has given very little snippet to work around from common users to keep your folder hidden.

  37. sam says

    Please help! I have locked the folder but now when prompted to open with password the folder will not reappear. Is there any way to get my files back? where to they go to?

  38. says

    Hi Mike,

    Can you please explain about this below step
    “Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}”

    As i removed the above step from the program and ran it. after that all the folder and files have been Hidden on my desktop.
    i am not getting those again.

  39. Rlf says

    It is so simple, it works great! When I saved your updated text, the “pwd123″ saved as “???” wildcards for the password. you can enter that, or just change it to whatever you want. Just take a closer look before you complain.
    Good Job!

  40. captain-murphy says

    Worked great. You have to run the .bat file twice, first to create the folder, second to lock it (and third to unlock it). It works best if you download his .bat.txt file.

    Also it was flippin’ easy.

  41. bayoujim says

    It works on XP pro 64 bit, after changing the quotes and file/folder names to something less noticeable than personal.

  42. Joseph says

    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?!

  43. ravi shankar says

    Hi

    this is working great…but i have a query …..suppose i have forgot the password so how can i retrieve that

  44. mike says

    @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?

  45. mkumar says

    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.

  46. mike says

    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

  47. mike says

    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

  48. says

    @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.

  49. mike says

    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?

  50. says

    @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.

  51. says

    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.

  52. jay says

    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!

  53. ME says

    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.

  54. says

    @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.

  55. Ravi says

    Hey…
    its in not woking PWD step….
    it is taking any password…..

    please try to make the folder visible after locking.

  56. says

    @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.

  57. SB says

    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.

  58. says

    @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.

Trackbacks

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>