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

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.

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

Enter Your Email Here to Get Access for Free:

Go check your email!