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 require the use of some third party software, but we have a neat method for hiding folders with a quick batch script.

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

Warning: if you are a beginner you should not do this. We get emails once a week from people that don’t know what they are doing and complain they can’t find their files anymore. We also have instructions at the bottom for how to see the files again should you forget how to see them.

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. Create it anywhere and name it whatever you want.


Create a new text document inside your new folder. You can do this by right-clicking anywhere in the folder and choosing New > Text Document.


Open the document in Notepad. Copy and 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 in your text document to the password you want to set. You then need to save the file as a batch file. From the File menu, choose “Save as.” In the Save As window, select “All Files” from the “Save as type” dropdown. Name the file “locker.bat” and then click “Save.”


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


Next, double-click the batch file to run it. The first time you run script, it will create a folder named “Private” in the same folder where the batch file is located. This “Private” folder is where you will store all your secret things. When you have finished adding all your stuff to the Private folder, run the “locker.bat” file again.


This time you will be asked if you sure that you want to lock the folder. Press the “Y” key and then 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 simply terminate.

How to See the Files Again

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. To see the files again, all you have to do is uncheck the boxes for “Show hidden files, folders, and drives” and uncheck the box for “Hide protected operating system files”.

But 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 08/31/14
  • Edward Gudz

    First : If the folder is not visible and the batch file is not named anything blatant to give it away then you really have nothing to worry about, if not then you should not be hiding folders.

    Second: Convert the batch file to .exe, most do not know how to decompile an .exe file, this will give you an extra level of security.

  • Alejandro Roger Ull

    Not again please, this is confusing for newbies and actually innacurate, as you are not protecting a thing. The last time you did this BAT thing to pseudo-password protect a folder a bunch of people complained in the forums that they could not unlock the folder and lost access to their data because of misuse.

    I totally recommend against this method. You should better explain just how to make and unmake a file a hidden and/or system file both through GUI and CLI and leave the BAT thing.

  • StarsLikeDust

    Echoing Edward_Gudz its important to note that your password will be easily accessible by anyone who opens the .bat file.

  • Andrey

    Do not encourage people to use this tip, is insecure. Instead, encourage the use VHD and BitLocker.

  • CogniView

    I think that, in an environment where you don't have to worry too much about other users having the knowledge to easily overthrow your efforts, this is a good little hack. Obviously it's not meant for keeping extremely sensitive data safe, but for a quick trick to keep prying eyes out of your business, it's not a bad option.

  • Charles Jones

    Perhaps Secret Disk (free and $14.95 Pro) is a better option. There are two levels of password protection and the folders and contents are hidden.

  • Erik Hicks

    OMG - seriously??This is the kind of 'tip' I'd see in an article way back in the days of Windows 3.1! There's much better ways of 'hiding' a folder. How about setting the NTFS permissions to only allow your account to access it and its contents? How about using an encrypted storage container using TrueCrypt or BitLocker? And yeah, simply editing the "locker.bat" file would reveal the password.

    I'm floored, HTG. LOL! Seriously... I gotta laugh and be dismayed at the same time. April 1st is long gone, guys.

  • Lowell Heddings

    Right at the beginning of the article we mentioned that this trick won't stop anybody that knows what they are doing.

    And then at the end of the article we showed how to display the hidden files, and even how to get your password back should you forget it.

    It's meant to be a fun trick, not a place to store your bank account details. Most people will probably use it to hide stuff from their more clueless relatives.

  • Banana From Redlight

    Can i rename my folder?

  • cha

    There are additional steps you can take to make this more secure - at least in the social engineering sense.

    Say you want to hide a bunch of files. Here's what you can do to add as many hoops as you can for people to jump through.

    Put them on a USB drive, so that you can physically hide it someplace.

    Copy a bunch of random system files from your computer. This is to add a bunch of noise for snoopers to have to sift through. So now your top level of the USB drive should have tens if not hundreds of random folders and files.

    add an innocently named folder to this directory. Say "cgi-bin" or something that blends in..

    inside this new folder repeat step 2.

    Add more folders that seem innocent enough, add more junk files. small text files that don't take up much space.

    Once you've sufficiently buried your "secret" folder. Place this locker.bat file here, rename the folder from "private" to something less conspicuous, like "dir" for example - again, something that will blend in to the surrounding folders and file names.

    Run this script to password protect and hide this secrets folder.

    Then when that's done. rename locker.bat to something random, like "00xb011.obj" something no one would bother to open - and even if they did, since you altered the file extension they would need to know to change it to a .bat file.

    9.Inside of your secret folder, take all of the files that you want to hide, lets say they're image files. change the extension from .jpg to something stupid and random like .mox...

    So now if someone wants to find your stuff, they'll have to either be really patient and determined, or string together several lucky guesses. Even if they found your files, unless they know what they're doing they will yet again have to guess the correct file extensions. If you surround each step of the way with tons of random junk it will only serve to convolute the process.

    then, whenever you want to access the files, you of course know the path to get to the folder. just rename that "00xb011.obj" back to locker.bat, use it, access the files, and then rename them back to .jpgs.


  • Nico De Klerk

    Your Idea with the USB stick gave me this revelation.

    Put the .bat file on a memory stick, then just add the next line after the "title Folder Private" linepushd "C:\location where you want to hide the private folder"

    That way the unlocker can be taken out of the Computer and no one can open the bat file to get the password. Basically turns your USB into a key.

    You can even use an autorun so that windows automatically unlocks the drive when the USB is plugged in however I dont know how you would lock it automatically when you remove the drive.

    Any Ideas on that?

More Articles You Might Like

Enter Your Email Here to Get Access for Free:

Go check your email!