How-To Geek

How to Create a Password Protected Folder without any Extra Software

There are a lot of methods that you can use to create a password protected folder, most of which require the use of some third party software. Using this neat method you can hide your folders with a quick batch script.

It’s important to note that this will not actually conceal your data from somebody that knows what they are doing.

Note: if you are a beginner you should be careful with this script.

Create Your Password Protected Folder

Before you get started you need to create a folder that will house your password protected folder, this is just an ordinary folder and can be located anywhere and named anything.


Navigate into your newly created folder and create a new Text Document. This can easily be done from the context menu.


Open the document, now paste the following code into the contents of the document:

title Folder Private 
if EXIST "HTG Locker" goto UNLOCK 
if NOT EXIST Private goto MDLOCKER 
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. 
ren Private "HTG Locker" 
attrib +h +s "HTG Locker" 
echo Folder locked 
goto End 
echo Enter password to unlock folder 
set/p "pass=>" 
attrib -h -s "HTG Locker" 
ren "HTG Locker" Private 
echo Folder Unlocked successfully 
goto End 
echo Invalid password 
goto end 
md Private 
echo Private created successfully 
goto End 

Change the PASSWORD_GOES_HERE text to the password you want to set. Now go ahead and save the file as locker.bat.


Once the file is saved as a batch file you can delete the original text file.


Now run your batch file by double clicking on it–the first time you run it, it will create a folder called Private. This is where you can store all your secret things. When you have finished adding all your stuff to the Private folder, run locker.bat again.


This time you will be asked if you sure that you want to lock the folder, press the “Y” key and hit enter to lock your folder.


You will see that your Private folder quickly disappears.


If you run the script yet again, you will prompted for a password.


If you enter the same password as you set in the script the Private folder will reappear if you enter the incorrect password the script will just Terminate.


Most people don’t know how to show system files, but anybody who has some experience will probably be able to quickly figure it out in the Folder Options.

Also, any ordinary user who unchecks the box will most probably be scared off by the warning message that appears.

The second way someone could comprise the folder is to open the batch file and read your password. It’s definitely not a really secure way to hide your files, but it is fun.

Attribution note: We found this script on dozens of different web sites going back many years. We have no idea who first created the script, so we’ve omitted any sort of attribution link. If you do have proof that you first created the script, contact us and we’ll adjust the article accordingly.

If You Forget Your Password

Seems like once a week somebody writes in asking how to figure out the password they set. And the answer is really simple: Right-click on the locker.bat file and choose Edit.

Then you can see the password you set in the file.

Taylor Gibb is a Microsoft MVP and all round geek, he loves everything from Windows 8 to Windows Server 2012 and even C# and PowerShell. You can also follow him on Google+

  • Published 02/20/12

Comments (62)

  1. Albert

    There is the possibility to create an executable out of the BAT file through certain programs (Google search for bat2exe or bat2com) – this way the password would not be able to be read out easily.

  2. Viraj

    Error !

    >> This time you will be asked if you sure that you want to lock the folder, press the “Y” key and hit enter to lock your folder.
    When this was asked I entered Y. And there was an unexpected error notice.
    And a new file of size 0 byte was created in same directory and folder is still visible. It did not disappear as expected.

  3. Mirso

    I can not create the Password Protected Folder

  4. dude

    This is very lame

  5. nirmal

    i also have the problem viraj said

  6. Keith

    doesn’t work with my Windows Home 7. It creates this file ö instead.

  7. jz

    Does not Work

  8. Lee smith

    I believe this is very bad practice and offers no real security

    Maybe only useful from hiding porn from the wife!

    Would better to have do a lesson on batch files rather than this lame example

  9. john

    Win 7 64 bit I tried like 5 times now the private folder wont disappear Don’t know what I am doing wrong
    when I click on locker.bat it does ask me if i want to lock folder I select Y and then it closes but it creates another File like this o.. the 2 periods are on top of the o
    any one got any ideas

  10. Frank

    I am getting the “0″ fault – applicable to others here, so what is the solution????

  11. gsrowens

    I get the same result as Viraj. Doesn’t seem to work for me in Win7 Home.

  12. emma

    Seems like we all having the same problem. Please help

  13. Taylor Gibb

    Hey guys, i just rewrote the script and updated the article, i have retested it and its working on Windows 7 Ultimate x64, tell me the exact errors you get if it still doesnt work and ill try help you out.

  14. Katina

    It worked! Yay! Thank you!

  15. Bill

    I just did it by going to command line (cmd) and running the batch file from there.
    Works fine.
    Simple, and thanks!
    Great on a thumb drive.

  16. sandeep

    Its working, but may not be much secure, i have testing it using some piece of software and found that has cracked this type of security.

  17. jp

    so stupid way

  18. Don

    You can use MS Word, put all your notes in a file and under “save as”, click “Tools”, “General Options” and assign the file a password.

  19. qwer

    the password is located in the bat file, everyone can open and see it

  20. mayasl

    Quite babyish! Can access the hidden folders by Windows Folder Options.

  21. jasray

    Guess it would be pointless to simply zip the folder, maybe encrypt.

  22. MJ

    I don’t think it is a good idea to teach this to anyone, as it may create a false-security expectation to someones. I can imagine some people storing it’s passwords or other sensitive info this way, or using their only password in the .bat too, so that anyone could get it. I know you warned them, but think this is dangerous and should NOT be done.

    As it has been said, encrypting a zip file would probably (surely) be easier and safer. I would recommend using 7-Zip’s .7z format with AES-256 encryption.

  23. Wolf

    What OS does this work in? I tried doing this in Windows XP Pro and it did not work. From the screenshots it looks like you used either Vista of Win7, please give us the OS that this works in.

  24. Aaron

    Hey guys, to those of you saying you cannot use on Win7 Home, maybe this will help.
    I was able to recreate the issue you are having. Try deleting only the “PASSWORD_GOES_HERE” with no spaces in front or after. A simple highlight and start typing your password will suffice.

    I have tried this on Win XP, 7 Home, 7 Pro and 7 Ultimate.

    Happy hunting.

  25. nonosh

    My Windows 7 setup:

    I use WinRAR on my seldom accessed files/folders to create a RAR or ZIP file with password encryption.

    For frequently accessed files, I store them in an external hard drive — or a flash drive — with BitLocker password encryption on the entire drive.

  26. Doreen

    This is Awsome! How incredibly easy to set up and use!

  27. Rakesh 619

    i agree with this tips but we can easily extract password from .bat file by dragging .bat into new text file . So this tips not be security its just way of hiding files.

  28. Janey B.Smith

    Thanks for the info, I’ve been interested in this for quite some time, and it’s great I found your blog

  29. emar1000

    For the nay-sayers you are right ; however he DID say that it wasnt totally secure and also mentioned at the end it was just for fun. For petes sake ease up and get the chip off your shoulders

  30. Frank Verano

    It worked fine for me. Win XP. The obious pitfalls is the slection of the parameters. It is good enough for the dasual snoop.

  31. freq

    Wouldn’t Alternate Data Streams be a better way to hide files? I think so.

  32. Galahad

    It’s working. maybe some of u just missed something. although i dont know wat wil hapen when some1 wil delete my locker.bat.

  33. btria

    It worked perfectly fine on my Windows 7! Thanks :)

  34. bluelord

    its a snazzy utility. well written short and neat program. works well even in windows7. HTG does it again!!! I mean the kind of stuff you learn here is in a whole different level in geekdom…

    you guys really rock in sharing such stuff.. keep it coming always forever!!


    get your own website, criticize the hell out of it and leave us poor uninformed startup geeks alone!!


  35. Ochinowa

    It runs perfect on Vista! Great!

  36. keitre

    its not really a lame but a simple hiding folders. the folders and files were just hidden and renamed but if the show hidden and system files are ticked, you can access the files. its not even protected but only hidden.

  37. kenedy12345

    Good to know about the How to Create a Password Protected Folder without any Extra Software

  38. Baback

    Thank you, it’s really fun

  39. eric mbithi

    it was successful in creating the batch folder but couldn’t open my folder after hiding it. don’t say i forgot the password coz i tried for 3 times but just couldn’t work. using windows 7 home 64 bit system.
    any way thank you for the lessons.

  40. Abhijeet

    The trick worked fine… thnkzz..:)

  41. Bauleni Chioza

    I was frustrated when thinking that some one will access secret information, but now I am happy for the development.

  42. Deej

    works for me. but not a reliable trick. Zipping a folder and encrypt it with a password is better.


  43. qwertyui

    have to say, this is a really stupid practice, even if the author was trying to teach some elementary kids

  44. Russ

    I just tried this cool little trick and it works great on my machine I love it, thanks howtogeek!!! 5 stars

  45. Thomas Franklin

    Nice works really well Thanks!!

    From Thomas Franklin

  46. wrussf

    FWIW, you can make an executable file from a batch script using iexpress.exe, which is likely already included in your version of Windows.

  47. fani

    works fine :D thank you !!

  48. sam

    A lot of CMD/batch stuff doesn’t work on Vista or above. D: that’s why I like xp

  49. c j

    follow the step and u can not go wrong. Make sure when u type passwd by replacing “PASSWORD_GOES_HERE” in the script; make sure do not leave any space before or after. The passwd should not exceed the space than this words in coma. Trusrt me it is easy. I have done with Window 7 and XP. both works fine. try again. Good luck

  50. JeffS

    Easier to just run Linux instead of Winblows and encrypt your entire Home directory.

  51. Frank

    Thanks for the tip(s), I have learned many things from you guys . . . .

  52. Victor

    I think it could be editable clicking the right mouse button and selecting edit option, with this can change the password easily, may would be a good tool for those people who doesn’t know so much about PC’s or some programming notion.

  53. Tony

    To all those slagging this off…. read this part at then end of the article …”It’s definitely not a really secure way to hide your files, but it is fun” , and this at the start of the article “It’s important to note that this will not actually conceal your data from somebody that knows what they are doing.”…..It was never intended to be a secure. It’s a bit of FUN !!!!!

  54. Joe


    Tried it out and its workin fine…..But whn “Show all hidden folders” is given it falls apart :D :)

    But theres an alternative way to hide your folder (windows XP).
    1. Run (window+r)
    2. attrib +s +h
    This will hide your folder and will not show up even if u hv selected “show all hidden folders”
    3. Now to bring back the folder
    attrib -s -h

    I believe most of u ll b knowing….Anyways Sharin is Caring rite ;) :)

  55. Joe

    follow up of previous comment

    attrib +s +h filepath
    attrib -s -h filepath

  56. creatgr8

    work perfectly-my Os-win-7

  57. Dale

    Or you could use TrueCrypt.

  58. Stupid South African

    You can add some registry tweaks in there to modify checked values and default values in super hidden and hidden files within explorer tab in the registry If you have trouble doing it mail me at

  59. D999

    Works Great! Have Windows 7 and no issues love !

  60. Ashwath-Shetty

    For more information on How to Create a Password Protected Folder without Extra Software you can go through the below link and here you will get the all details:

  61. miyanda

    Well it works fine for me. My boss was born in the fifties and he can’t figure out a thing. So until I find a geek boss am cool with this

  62. platsak

    sheez you guys can moan.

    its a fun exercise. they state that it is not very secure, so stop bitching about it.

Enter Your Email Here to Get Access for Free:

Go check your email!