Password Protect Folder Without Using Any Software in Windows

Protecting a folder with password lets secure your important and confidential data in Windows. What I noticed that generally people use third-party applications to lock a folder with password. We have already discussed about data hiding and file security in our previous articles. But this one can take the security to a new level without using any software. We shall lock a folder making it password protected and hidden so that, no unauthorized person can get access to its content.

There are tons of software, available in the market to hide or lock your folder in Windows. But, if the same thing can be achieved without any software then why you’d use a third-party tool which can itself contain vulnerabilities? In this article, I’ve described the process to lock the folder by creating a simple Batch file.

How to Password Protect Folder Using a Batch File

Step 1: Copy and paste the following codes in a notepad file. Make sure to replace the red section at line number 23 with your own password.

title Folder Confidential
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
if NOT EXIST Confidential 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 Confidential "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
echo Folder locked
goto End
echo Enter the Password to unlock folder
set/p "pass=>"
if NOT %pass%== Replace this Red portion with your password goto FAIL
attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" Confidential
echo Folder Unlocked successfully
goto End
echo Invalid password
goto end
md confidential
echo Confidential created successfully
goto End

[Source: Microsoft]

Step 2: Save the file as Key.bat. You are done. Double-click on the Key.bat file to execute the commands written into it. A folder, named Confidential is created automatically (this happens only first time you run the batch file). Now, move all of your confidential files and folders in that folder.

Password Protect Folder Without Using Software

Step 3: Double-click on the Key.bat file again to lock the folder. You will get a confirmation message in the command prompt. Type ‘Y’ to confirm. Now the folder (Confidential) will be locked and hidden.

lock folder using command prompt

How to Unlock the Password Protected Folder

If you want to get access to the contents of that locked folder then double-click on the batch file again. Immediately, you will be prompted to enter your password. Put your password and hit the enter key. The folder is now unlocked with the contents encapsulated into it.

unlock the folder using command prompt

By this process, you can password protect the folder and no body can get access to the folder without the password. But still there is some risk. If somebody is a computer savvy, he can easily retrieve the password from your batch file. He can easily find the password by choosing the ‘Edit’ option from the right-click context menu.

Must Read: How to Secure USB Drive With Password.

So, convert the batch file into an executive file to to prevent the password theft as no one can read the source code of an executive file. Here, I’ve described the process of converting a batch file into an executable(.exe) file.

Convert the Batch File into an Executive File to Lock the Folder

At first you need a compiler that compiles the batch file to an executable file.

1. Download Bat_to_Exe converter from here.

2. Now, run the application and put the source path of the batch file and name of the target executable file with location.

Executive File to Password Protect Folder

3. Click on the ‘Compile’ button.

That’s all. Delete the ‘key’ batch file. You can now lock or unlock the folder by using the executive file (key.exe). Your data is now fully protected.

The above method works in Windows XP, Vista and Windows 7. Password protecting a folder ensures the security of your important data. If comes for only images, you can password protect images to make them private and inaccessible.

Update: After getting some feedback from the reader, we modified the code and it should work properly.

Related Posts


  1. Mukesh :

    It’s nothing like protection, it makes the folder as system hidden, which can be accessed easily.

  2. WAQAR :

    It does not work well in windows 7.
    If you go to options and uncheck the option of protected system files.The folder will appear.
    Please help.

  3. aydin :

    But there is a big problem.

    Anybody who know this method when made a .bat file like this and use any password can open this private file.
    For example i made a private folder and my password is 123 and private file unvisible.
    and then i delete this .bat file which was password is 123, and i create new one and password is nonpasaran.
    password “nonpasaran” can open the file which locked password 123 !

    Any idea?

  4. WytaZzZ :

    Hi, i have tried this method in windows 7. However this code does not work at all you should recheck your code. But the code in source which you wrote.
    this worked well.

    By the way this is not secure. Open tools then folder options and select tab “View”. Then Uncheck: “Hide protected operating system files”. And you can freely and easily open that secured folder (however it is named something like “Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}”)

    So this is just a trick.

  5. Aakash :

    it doesn’t works with win7.
    When i click on ‘Key’ then command says “123 to unlock” but in your image it shows “Enter the password to unlock”

    • avnish :

      It’s a false statement given by Akash. Its working properly in window7.
      I am using the same.

  6. Tanmay :

    @Akash: Sorry for the mistake. I have made the correction. Now it should work fine. Thanks for your feedback.

  7. Tanmay :

    Though you can recreate that unlocking key by the above codes. And if you can remember the password, you will be able to recover that folder. But keep that key file in such a place that any one can’t find that easily.

  8. Bhupi :

    key.bat is not craeting the req. folder “confidential”.Kindly tell where it is created.

  9. Tanmay :

    @Bhupi: Copy the code by clicking the “Download the text version” link at the above post. It should work.

  10. devdin2 :

    Amazing really amazing site!…i should go through every tips of this site to be genius hahaha!

  11. TAS :

    Hi! My question is how to delete this .bat file completely and what if someone deletes the converted .exe too I mean then how will I get my stuffs back.

  12. Tanmay :

    If your folder is unlocked then just manually delete the file from its location by pressing the Delete button.

    For you second query: If you can remember the password then you can again create that bat file or exe file from this site and follow the procedure of unlocking.

  13. TAS :

    Yes, but I wanted to know whether or not the stuffs on the Confidential Folder will remain there or not

  14. sounak :

    after selecting yes option d folder doesn’t bcome invisible ……. rather a shortcut to control panel is created …….. can any one help me?

  15. win7_advanced_user :

    Works perfectly fine with win7. however, by going to organize-folder and search options-view, then hitting hide protected system files, the file can be revealed…

  16. Josie121392 :

    I made everything the way it says, I followed it step by step, and it works, but why is it that when I click to unlock the folder, where that little pop up appears about inserting the password, it doesnt ask me that, instead it GIVES me my password and all you have to do is press “y” and enter and it opens the folder.. Help me please??

  17. gaius :

    I finished all the steps (1..2..3.) then I put my files inside the Confidential folder, then i converted bat to exe, but when i opened key.bat and key.exe by password my files are missing.
    Please someone help me to get my folder back!

  18. mostafa :

    I have a question, how to prevent any1 from deleting the file (key) plz if anyone knows how , i would be very grateful thx…

  19. ali khan :

    can you change the folder name from confidential to something else???

  20. Tanmay :

    Yes Ali. Just replace the word confidential in the code with your desired name (make sure you replaced all)

  21. Disorder :

    Nice easy and requires no software. But if someone delete this key file folder is lost, right? I tested it and i couldn`t reach this cofidential folder anymore after deleted hey file

  22. Lester :

    can I rename “Confidential” to anything I want? ‘Cause there are 2 that I need to lock.

  23. Minea Bogdan :


  24. qenezela :

    works well on win 7,at first it didnt,one juz gotta do steps as outlined.
    still to check whether it is compromisable though

  25. gopal :

    the folder that is locked, can be deleted by any body without asking password
    can u give me any suggessions

  26. sreenivas :

    this is very nice folderlock thankyou verymuch. but anybody will delete the key.bat. so, i think this code is very fine if it is when undeletable file (key.bat)

  27. B Rhodes :

    Other than that, for a ‘no software required’ protection, it is a very good solution.

    Yes, it can be gotten around, but by it being hidden, the folder is less likely to pique someone’s curiosity to try and see what is in it.

  28. vishal :

    hey guys….any idea we can protect external USB hard drive data…i hav tried few softwares..but either they all are not working properly or the became trial versions…and hav limited use like 3-5 times.anybody hav USB secure with crack….working…pls do let me know will b great help…take care

  29. Jeff :

    Windows 7 Ultimate SP1 Here. It works perfectly on my PC. Thanks for sharing this tip: How to Password Protect Folder in Windows. More power!

  30. maddy :


  31. maddy :


  32. SATISH :


  33. nnn :

    how do i retrive the folder i locked ?
    as i m not getting Confidential folder after double click key.bat.
    i have recently formatted my computer.
    plz help me getting this folder

  34. sam :

    If we hide a file lets say sam.jpg, it wont show up.
    But if we search sam.jpg, file is found even if its hidden.

  35. vanitha :

    Hi It works good, but after I attach and send this file through the outlook email to other person, it goes to unlock. After that, the file retains in unlocked condition. How can we lock the file, after it is attached through email?

  36. shaks :

    dear, but when the .bat file asks for password, even if i enter any incorrect password th3e folder gets disclosed, is thr some mistake in the code, or some other trick will do

  37. mike :

    here is an simpler program that i am working on can you give me some advice about it???

    @echo off
    taskkill /f /im “explorer.exe”
    set /p Answer= Please enter password
    if /i {%ANSWER%}=={YOUR PASSWORD HERE} (goto :yes)
    goto :start
    START explorer
    echo correct password

  38. Prakash :

    But the key file will unlock the confidential with wrong password also.
    Please Help.. Reply on My Email. ID :

  39. ganesh :

    thanks it worked…. but while typing password it is visible…can you make it like ****** way

  40. krashnil :

    i have created the file successfully but wen i double-click it…no new folders r created
    im using win xp
    file saved on desktop
    help plz

  41. Habib :

    thanks for this .. it really works…. great technique. i’ve tried it in several way e.g. with removable devices,email. it’s really awesome…

  42. 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 that you want:

  43. ambuj :

    if key.exe file is deleted how can i retrieve the confidential file after making it hidden or protected? please reply,if anyone has got soln. to this.

  44. imdad :

    i think this is not very well because if some one who has already read u r post or saw this post somewhere can get the password of the bat or key file easily.when he.she right clicks and then goes in edit in the key file there he/she can see the password and then simply type that and can open the files and the folders

  45. AKRANJAN :

    If file and folder are selected to view hidden and system files & folders then browsing shows all files and folders which has been hidden and making password protection useless.

  46. Amey :

    Actually i have locked using your way and even some of softwares
    but this is not working i can open the confidential file without
    giving password plz help me out with dis problem

  47. Rambo :

    There has a one more problem in this method. In this process there has no certain password. How many times I open the batch file I am asked to given a password & when I give a password the folder opens but after this when I am again open the file & then if I enter other password then it is opened.

  48. Armando :

    After you lock the folder, you can move key.bad in one other position that only you know…Maybe this is a solution

  49. crin99 :

    I have some question?-where from new script .bat stores/reads the password??? it is working on Windows xp???

  50. hassan :

    bro when i press y .. the considential folder changed its name to control panel{21EC…. etc}.. what is its solution

  51. vikas :

    It was really an easy process rather than downloading and installing processes. I followed it. But in case if password is forgotten how can i retrieve it manually???

  52. shrawan :


  53. Faid Alfarisi :

    Try my new edited Folder Lock, see it here “”…

  54. sunil :

    dude.. i have been using this folder lock from a very long time.. recently i locked all my files in this and some days later, i was not able to find the locker.bat file…. and all my files i tried recovering through my recovery software … even that didnot help… please help

  55. sunil :

    i know the drive but dont know which folder it was in… and i cant even see the locker.bat file…but i do remember the password

  56. Tanmay :

    @Sunil: Well, There are two ways for you…
    1. Memorize the folder path and create another unlocker file with that.
    2. Install Linux or use a Linux live CD. You can then find the folder you made hidden.

  57. Edited :

    the initial article bat file does not ‘secure’ or ‘lock’ the folder, just renames and attributes it. Anyone can locate the renamed folder with hidden/system folder views enabled. Faid Alfarisi bat file seems to actual lock the folder properly.

  58. Faid Alfarisi :

    @Edited : Really, thanks for it,,, in my first reply in this post, i copy my bat Folder Locker file, but i lost some symbols, like the “” symbols, so it does’nt work, n i gave my blog link to solve this problem,,, Have you visit on my blog and see the real file of bat Folder Locker…??? Reply.

  59. Faid Alfarisi :

    @Edited : Really, thanks for it,,, in my first reply in this post, i copy my bat Folder Locker file, but i lost some symbols, like the “BackSlash” symbols, so it does’nt work, n i gave my blog link to solve this problem,,, Have you visit on my blog and see the real file of bat Folder Locker…??? Reply.

  60. akash :

    it doesnot works even if any one has typed wrong password it show you the folder and you can easily access it
    and bat doesnot wait for writing the password for first time

  61. xxx :

    this not so protected when we right click that key.bat file and click on edit the password is visible it can be easily opened

  62. kartik :

    it is not showing backward slashes so i hve put * in their place
    and reposted:
    the easy way out:
    open command prompt
    go to the directory the folder you want to hide is in.
    type the following:
    C:users*admin>attrib +h +s foldername
    this hides your folder
    to unhide:
    C:users*admin>attrib -s -h foldername

    to do this to a file:
    C:users*admin>attrib +h +s filename.extension
    this hides your folder
    to unhide:
    C:users*admin>attrib -s -h filename.extension

    supposing that you want to open the folder movies in drive d:
    1. open run
    2.type cmd
    3. type driveletter ie. D: etc…
    4.type “cd directory name”-without quotes
    email me at:

  63. vicky :

    hey the confidential folder open by any password . suppose my password is hero but if i will write any key like h as password the confidential folder will be open.

  64. Kartik :

    @Mukul you need to create a .bat file (see tanmay’s description)you can then hide your batch file to keep it safe.
    You cannot use the “attrib” command to set a password for a file
    note :you mauust remember the folder/file’s name to unhide it

  65. shako :

    hello everybody, I’ve tried this and it works properly, but i have one question, I’ve created this bat file and than exe file into shared documents folder, because I want to share this “confidential” folder in workgroup computers, could you please help me how to access this file from another computer ??

  66. shako :

    i want to access this hidden folder from another computer which is the member of workgroup and shares files with this computer and has a shared folder with this computer

  67. Raj Dhiman :

    Everything is good about it.but when i am typing the password anyone can see easily. i want to se ******* when i am typing the pasword.

  68. Faid Alfarisi :

    @Raj Dhiman : It’s impossible to make star input, cause this program run in DOS mode, i don’t know how to make it possible,,,

    NOTE : if anyone know how to do that and want to help me, please tell me…???

  69. Rdub :

    This works just fine on Windows7. Unfortunately the files are still accessible through the search feature. Even with the file hidden all you have to do is search for it and there it is.

  70. shubham :

    not working on win soon as i’m locking the folder it’s name changes to ‘Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}’..but it’s still accessible without pass…

  71. bradley :

    …is there any solution if you want to set a permanently view or automatically view your files in flashdrive in thumbnails…is there a code in notepad…jeje i just wan’t to know..

  72. tibebu :

    10Q very match my file now protected would you mind help my problem is some body reuse my web site or my history on the opera Internet connection so who can protect ,still to see and use.please help me

  73. vaishali :

    hey…thnx a ton!!but i have a problem using it.As whenever i am typing anything when it is asking for the password,the folder gets unlocked automatically…i mean the passwords are not working.i tried it many a times…Please help!!

  74. ahsan :

    the password is only for showing folder will be unlock what ever i type there
    is there any safe way to use password

  75. Hemant :

    It works fine but there is an issue, it still opens the file if you enter a wrong password. To solve this issue just add “goto” before “FAIL” where it asks for the password, shown below,

    if NOT %pass%== YOUR PASSWORD goto FAIL

    Hope this will do!!!! :)


  76. Waldo :

    Well, here is mine if anypony is interested, it’s much more secure than this one imho, but uses the same method of hiding it.

    Here is the batch file:

    title Folder Private
    if EXIST “Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}” goto UNLOCK
    if NOT EXIST Private goto MDLOCKER
    echo Locking….
    goto LOCK
    ren Private “Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}”
    attrib +h +s “Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}”
    echo Folder locked
    goto End
    attrib -h -s “Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}”
    ren “Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}” Private
    echo Folder Unlocked
    goto End
    md Private
    echo Private created successfully
    goto End

    You’ll notice that this one doesn’t ask you for a password…..Thats the point. The password is useless, and when you type it in to command prompt it will show the pass as you are typing it. I considered this fairly insecure. I noticed a neat feature in the Batch to Exe converter the author put up. It has an “Encrypt the program” option, and it hides the password as you are typing it. So I made this batch file, (which when opened hides the folder, and when opened again makes it visible) and used that feature, along with the converters “Invisible Application” option (so the command window stays hidden, that way the have no way of guessing it’s batch.) I also added a little padlock icon with the icon feature on the next tab. Now when you open “Key.exe” you get a password prompt in windows not cmd, and it has the same effect. Post back here with questions, I’m sure somepony else has come up with this already, but I thought I’d share since I couldn’t find it on here. Enjoy. :)

  77. sunil :

    this is not useful in anyway at all.
    First of all, the confidential folder created by the batch file is not password specific at all since we can open it by any arbitrary key typed after opening of command window (called as “password” by author).
    Second if the batch file is deleted by any person, then there is no way to retrieve the hidden or so called protected “confidential folder” back.

  78. gggirlgeek :

    Better: Simply download EaseUS Todo Backup (free.) Create a backup image of whatever you want. On the last page, where you “Select the backup destination”, open the Options button at the bottom.

    Select the Password tab and there you’ll see a choice between 4 levels of encryption, up to AES 256 (I use this.) Type your password twice and hit OK. Then proceed with the image archive. I’ve tested all 4 levels for speed on a large partition. The highest level made very little difference. (High compression is what brings this little gem to it’s knees!)

    This is my security solution because the archives that are created can be opened and used just like regular zip files as long as EaseUS is installed (the portable boot CD/USB version is fine too.) It also does not use an external encryption key, so you won’t get stuck if you move your file off of the computer where it was created. (Tested that too.)

    Last, I found out the hard way that EaseUS’s encryption is indeed secure. Some large system backups got deleted from my drive. It turned out I needed them badly. Unfortunately my recovery programs were able to piece together 1000’s of undamaged files, but the encrypted files just came out a scrambled, random mess.

  79. Faid Alfarisi :

    Why using BATCH file if you can make Folder Locker with Visual Basic Script (VBS) file, come to my blog and see it here “”

    and if you want a BATCH Folder Locker, you can see it here “”

  80. Yousef :

    Hiii, thanks so much! u r so helpful, i was searching for maybe half an hour for a password lock without downloading, and thank you so much, i came across your awesome website! Thanks for that mate

  81. Gilan :

    Hi Every One ^_^
    This COde is Good for XP only.
    Try it, and get Ready for your smile.

    title Folder Locker
    if EXIST “Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}” goto UNLOCK
    if NOT EXIST Locker goto MDLOCKER
    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
    ren Locker “Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}”
    attrib +h +s “Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}”
    echo Folder locked
    goto End
    echo Enter password to Unlock folder
    set/p “pass=>”
    if NOT %pass%==type your password here goto FAIL
    attrib -h -s “Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}”
    ren “Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}” Locker
    echo Folder Unlocked successfully
    goto End
    echo Invalid password
    goto end
    md Locker
    echo Locker created successfully
    pause >nul
    goto End

  82. Muhammad Haris :

    nice trick… ..but i can still access the folder using winrar… ..a control panel icon appears using winrar opening it you access folder.. ..any solution for this…

  83. Me :

    Right click .bat file, edit, there’s the password. bat files are not secure. I would refrain from this method. Anyone with the smallest computer skills can crack this.

  84. Jody Lang :

    It works okay for me
    you can rename confidential just like you would any other folder
    Faid alfarisi, the code you posted does not work with windows 7 i tried.

  85. Juan :

    I am trying to use this batch file in a shared external hard drive (an external HD connected to my network) and the only problem is that it does not make it hidden. I tried renaming the folder and putting a $ sign at the end, but it is the same. Do you know how to change the attributes (using batch commands) of folders in a shared external HD? Thank you for your help in advance

  86. Juan :

    I am trying to use this batch file in a shared external hard drive (an external HD connected to my network) and the only problem is that it does not make it hidden. I tried renaming the folder and putting a $ sign at the end, but it is the same. Do you know how to change the attributes (using batch commands) of folders in a shared external HD? Thank you for your help in advance!

  87. Mythili :

    Thank you.. It works fine for me..

  88. swaroop :

    The method mentioned is useless. The protected folder can be accessed easily.

  89. Sabin Neupane :

    Does it also work in Windows 8?

  90. MADHAV :

    Very helpful article. Thanks for sharing. Here also you can get tricks for password protected folder :

  91. Jilline :

    How do I change the password after converting the file to exe?

  92. shiva sathiya :

    I just reached to your post, I found that is good. I read it careful I found that this is really interesting thing.

  93. GM :

    What if I forgot my password with the batch file ? I tried finding it using right click edit, but could not. Any fix ?

    • Tanmay Ahmed :

      You should change the password from the source file. If you can’t see anything at the password field, try putting another one.

  94. sonia :

    I protected some file with the protected folder software, but after new windows set up I lost that what can I do?

    • Tanmay Ahmed :

      Create similar lock file with similar password. Then follow the unlocking process.

  95. iMade :

    Yeah man it will work fine. But you need to store your password some where else so no one can see it by rightt-click >> edit. Refer the link for that. Its another batch file you can use .

    Don’t forget to give your feedback :)

  96. kranthi :

    I had one idea to overcome from that risk. The idea is to hide the .bat file then no other can see that file to edit.
    how is it?

Leave a Comment

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