Create a password protected folder without any special software

Posted on 08 January 2008


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!


Print | Email to friend

38 Comments For This Post

  1. SB says:

    Doesn’t work(In XP).The folder does get created,but doesn’t get locked or anything.

  2. Suresh 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.

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

  4. Niyaz PK says:

    looks like a big task. Make it into a software… You could give it away for free in this website..

  5. Niyaz PK says:

    It seems like I am an aussie… :)

  6. Suresh 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.

  7. SB says:

    Still doesn’t work..

  8. Suresh says:

    @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

  9. mk says:

    hi it nise.But the folder open with any key
    without password)in WINXP.
    regards
    mkumar

  10. rambhai says:

    hey it worked in my xp~~~thanx mate~~

  11. ecchi says:

    doesn’ work if you use Xnview (or any type of image manager, you can still see the content of the folder)

  12. C FRASER says:

    It hides the folder ,requist for a password but any password typed makes the file visible

  13. Ravi says:

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

    please try to make the folder visible after locking.

  14. Suresh 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.

  15. vicky says:

    very nice trick

  16. mk says:

    hi boss its working. thanks for your efforts.

  17. cg says:

    I got it to work and the file is hidden but now I can’t unlock it, it is not taking my password.

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

  19. 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!

  20. Vikrant Kumar 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.

  21. Suresh 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.

  22. Suma says:

    Hey,
    Thats really a nice program
    Thanks for that
    Good Day

  23. mike says:

    i downloaded the batch file and i dont know the password

  24. 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?

  25. Suresh 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.

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

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

  28. mike says:

    then name the batch file to: open and close the lock

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

  30. 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?

  31. mike says:

    WHERE IS THE HIDDEN FOLDER GO WHEN LOCKED?

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

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

  34. mike says:

    right click the batch file and click edit

  35. vj says:

    excellent work dude

  36. mike says:

    vj says:
    excellent work dude

    me?

  37. sahil sharma says:

    please how create a folder with protected password

  38. mahi says:

    great work man… i have to develop like this only… thanks..

Leave a Reply

Quick Tips

  • Zooming in Firefox

    In Firefox,  zooming in and zooming out is very easy. Hold down the Ctrl key and scroll the mouse wheel away from you to Zoom in and towards you to Zoom out.


  • Recent Comments:

  • Subscribe to Digital Quest


     Subscribe to Digital Quest via RSS


    Or, subscribe via email:

    Preview

    Choose Language

    English flagItalian flagGerman flagSpanish flagFrench flagPortuguese flag
    Japanese flagKorean flagChinese flagArabic flagRussian flag 
    By N2H

    Warning: stristr() [function.stristr]: Empty delimiter in /home/ideasfor/public_html/dq/wp-content/plugins/wassup/wassup.php on line 2093