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


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.

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.


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.


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.




One thought on “Password Protect Folder Without Using Any Software in Windows”

Leave a Reply

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