Sometimes privacy is important for all of us, especially when you use a common computer in a family. You may be interested in protecting a personal file or folder from someone accidentally opening and viewing the content. Unfortunately, when it comes to protecting a file or folder in Windows PC, there is no such default features to do that specifically. Though other editions of Windows do provide you with an option to encrypt your files or folders, Windows Home edition sometimes does not do that. There is an option to hide your files/folders but it’s just for the hiding or showing purpose.
So, if you want to protect your files in Windows PC, there are some tricks and third-party apps which you can opt for. In this guide, we will show you how to do that.
Password Protect a File or Folder in Windows
There are three methods in this guide and all are pretty easy, you just need to follow the steps in order. Though we have already tested these methods, take a copy of your file / folder which you can delete after confirming one of the methods works for you. Otherwise, create a sample folder for yourself and add some sample files in it to test with dummy content.
1. Using a Locker Folder
Make sure that you are trying this method only with the files and not with the folders because this method will not work on folders.
- Go to the folder inside which you want to password protect the files.
- Copy and paste the below code inside a Notepad document and save the text file. You can give any name, let’s name it ‘PasswordPro.txt’.
cls
@ECHO OFF
title Folder Locker
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
if NOT EXIST Locker goto MDLOCKER
:CONFIRM
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
:LOCK
ren Locker "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
echo Folder locked
goto End
:UNLOCK
echo Enter password to Unlock folder
set/p "pass=>"
if NOT %pass%==Enter-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
:FAIL
echo Invalid password
goto end
:MDLOCKER
md Locker
echo Locker created successfully
goto End
:End
- Move this text file to the same folder in which you want to protect the files.
- Open the ‘PasswordPro.txt’ text file and go to the line having the text ‘Enter-Your-Password-Here’. This is a placeholder text and change this with your own password. We use the password ‘enjoytheevening’.
- Go to ‘File’ options from the top menu. Click on ‘Save as’ and select ‘All Files’ from the bottom ‘Save as type’.

- Give your file a name with ‘.bat’ extension. For example, ‘PasswordPro.bat’
- Click on ‘Save’ button. Basically you save the ‘PasswordPro.txt’ file into ‘PasswordPro.bat’ file.

- Double-click on the file and a new folder named ‘Locker’ will be created in the folder.

- Move your files inside the ‘Locker’ folder.
- Double-click on the file ‘PasswordPro.bat’ and it will ask you to lock the locker folder in a Command Prompt window.
- Type ‘Y’ and press ‘Enter’ key. The window will close and the locker folder will be hidden.

- The only files which will be left are ‘PasswordPro.bat’ and a text file ‘PasswordPro.txt’ which you have created.
- To unlock and see the folder again, double-click on the ‘PasswordPro.bat’ file.
- It will open up a new Command Prompt window and ask you to unlock the folder. Enter your password which you have set in the previous step, ‘enjoytheevening’ is our password.

- Press ‘Enter’ key from the keyboard and it will show the locker folder again.
- Repeat the steps again to hide and password protect the folder.
Now, you can delete the ‘PasswordPro.txt’ text file if you want. You can also move the ‘PasswordPro.bat’ file to a different location. But the problem is you won’t be able to see the files in any other folder/drive/path in your hard drive. If you are moving this file, make sure to remember the original path where the files were hidden. You need to move this ‘PasswordPro.bat’ file back to original location and then use it for locking/unlocking the ‘Locker’ folder.
2. Using a Third-Party App
There are many third-party apps which help in protecting your files/folders with a password. WinRAR is a software which allows you to compress/archive your files/folders as well as protect your files with a password. You can also use WinZip app to compress and set password to the archived file. To do this:
- Download and install the WinRAR from their official website.
- Go to your file/folder and right-click on it.
- Choose ‘Add to archive’ option.

- Give this file a ‘Name’ and click on ‘Set password…’ button.

- Enter ‘Password’ in the given field.
- Make sure you check the option ‘Encrypt file names’.

- Click on ‘OK’ and then ‘OK’ again to close the dialog boxes.
Now, your file has been secured with a password successfully. This method is very effective and should suffice to protect any of your file / folder. In case you want to password protect an application file, then this can be hectic. You have to extract it every time. Also, you should delete the original folder after archiving it.
3. Using In-built Feature of Windows
This encryption feature is only available in Windows Pro and other versions except Windows Home. This is not a complete password protection, it only does not allow other user accounts on Windows to open your files.
- Right-click on your file and select ‘Properties’. You can also highlight a file and press ‘Alt + Enter’ keys to open ‘Properties’ window.
- Under the ‘General’ tab, click on the ‘Advanced’ button.

- A new pop-up will open and you need to check the option ‘Encrypt contents to secure data’.

- Click on ‘OK’ to close ‘Advanced Attributes’ dialog.
- Then, click on ‘Apply’ on the ‘Properties’ dialog and you will be prompted whether you want to encrypt the file or the parent folder also. Select your option and click ‘OK’ button.

- A small notification pop-up will appear asking you to backup the encryption keys. You need to click on that and export all the keys to a file and save it.

- If you missed the notification, click on the arrow in system tray section and then click the ‘Encrypting File System’ icon.

- This will open a wizard, select ‘Back up now (recommended)’ and export your encryption certificate and key. You can use this backup in case if you are not able to access the encrypted files.

Encrypted files will show a padlock icon on it indicating it is protected and deny access to any other user on your system trying to access the file.
Conclusion
Sometime you only need to hide the files from others and not protect with password. In such a case, simply right-click on the file or folder and go to ‘Properties’. Here you can set the attribute as ‘Hidden’. You can also hide or show the files from File Explorer or File Options settings. If you really wanted to protect with password or encrypt a file, then follow one of the above explained methods in Windows PC.






thank you so much. first option worked very well.
All mentioned solutions are not very practical. When more people in one house make use of the same PC, they can still see the names of subfolders and files
First one didnt work… seems a little suspicious as to what it actually did then…
The first one did work for me when I dragged and dropped my file in the locked
works fine with me.. thanks
I tried method 1 (using a locker folder). Instead of of the folder “Locker” disappearing, it appeared as another folder named as” Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D} ” and it can be opened without any password. Quite defeats the intention?
I happened to already have WinRAR and never knew it has such feature. Thanks a lot.
P.S. I wonder what else I don’t know.