How to Password Protect a Folder or File on Windows PC

Have you ever been stuck in a situation wherein you simply can’t share your PC with your friends, colleagues, etc? Not letting others access your PC is of course the best to protect your personal data. However, there comes a time, when we reluctantly let our friends and relatives use our computers. Well, if you too have to take such difficult choices, you can always password-protect a folder or file in Windows 10.

Doing so, you don’t need to be rude each time someone asks for the PC. Rather, you might be able to share your device without worrying too much about your personal information. 

Ways to password-protect a file or folder in Windows 10

There are three different ways to password-protect your sensitive data in Windows 10 which are Creating and Running a batch file, making the important folders hidden, or using the Windows BitLocker. Let’s explore these methods in detail –

1] Create and then Run Batch File

Users may password-protect their folder or file in Windows 10 by using a batch file. Creating a batch (BAT) file involves a series of steps that you must perform carefully. Overall, this is a simple yet lengthy procedure. Here are the essential steps to work upon –

Create a Batch File

Quick Note: You may download our batch file, and unzip/paste it directly to the folder that you want to hide. 

  • First of all, create a file and name it whatever you have in your mind.
  • Make a right-click anywhere inside a folder (just remember its path) and select New > Text Document.
  • Next, double-click on the .txt file to open it, and paste the below set of codes –
title Folder Locker
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
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.
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%==your_password 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
goto End

Tip: Scroll down to “if NOT %pass%==your_password goto FAIL” and replace the “your_password” part with your own password. 

password protect a folder or file in Windows 10

  • Next, press the “Ctrl + Shift + S” keys together to open the “Save as type” window.
  • Fill any name with a .bat extension inside the “Filename”, and change the “Save as type” section to “All Files” using the drop-down menu.

Save As type

Run the Batch File

Imp: If you have downloaded our file, right-click on the file, and click Edit. When this file opens up with notepad, go to the “if NOT %pass%==your_password goto FAIL” line and replace your_password with your own password.

  • Now, open the folder containing the batch file. Subsequently, right-click on the batch file and hit Run as Administrator.

Run Batch file as Administrator

  • You will notice a new folder titled “Locker” appearing there. This now works as a locker for all your personal stuff – data, pictures, files, etc.
  • Just open this folder and place all the essential items here. 
  • Double-click on the Batch file and this redirects you to the command prompt.
  • Press Y then Enter to lock the folder.

password protect a folder or file in Windows 10

That’s it, you will no longer see the “Locker” folder.

How to access the Locker folder

To re-open the locker folder, follow the below guideline –

  • Make a right-click on the batch file, type the “password you created” on the prompt, and hit Enter.

password protect a folder or file in Windows 10

  • If you have entered the correct password, you may see the locked folder once again. 

Tip: It’s better to hide the batch file using the below method. Otherwise, one can easily modify the password by opening the batch file with notepad. 

2] Hide your Files/Folders

The above method is best suited for protecting personal data, pictures, folders, etc. However, at times, we just want to keep a few folders far from the reach of kids or others. If that’s the case, there’s no need to follow complex steps as guided above. Instead, you can hide the specific folders so that no one accesses them normally.

Note: This method is not totally secured as anyone familiar with this may access the hidden folders.

Here’s how to proceed –

  • Right-click on the specific folder and hit Properties.
  • On the Properties window, head over to the General tab.
  • Tick the checkbox left of Hidden under the Attributes section and hit Apply then OK. See the Snapshot below –

password protect a folder or file in Windows 10

In general, performing the above task hides the particular folder. However, if you are still able to view the hidden folders, this implies that Windows 10 is set to display hidden files or folders. 

To set Windows not showing hidden files or folders, follow the below guideline –

  • Go back to the folder containing the hidden files/folders and click the View tab. 
  • Next, hit Options and hit “Change folder and search options”.

password protect a folder or file in Windows 10

  • Go to the View tab on the succeeding Folder Options wizard, mark the radio button “Don’t show hidden files, folders, or drives”, and hit OK.

Don't show hidden files or folders

  • That’s it, you must not be able to view the hidden folders now. 

Tip: To view back the hidden files or folders, you may read this article

3] Using Windows BitLocker

Windows BitLocker is an in-built tool on Windows 10 that helps to secure files and folders. However, it has its own limitations. First of all, this utility program is available only to Windows Pro and Enterprise versions only. In case you are using a Windows 10 Home version, you may skip this method. Moreover, this tool can’t lock a specific file or folder, rather this protects the entire disk drive.

If you meet the two conditions cited above, follow the below steps to encrypt any disk drive –

  • Jointly press Win+E to launch the File Explorer and click This PC on the left column.
  • Make a right-click on the particular drive and hit “Turn On BitLocker”.

Turn On BitLocker

  • The system will then prompt two ways of locking the drive i.e. “By Password” and “By Smartcard“.
  • Choose either of the options available there and tap the Next button.

Quick Note: A pop-up menu will appear asking where to save the recovery key. Keep this key somewhere safe and secure.

  • The system will let you choose to encrypt either the whole drive or just the occupied space. 
  • Select whichever option suits you the most and click Next again. 
  • Wait for a while as this takes a few minutes to complete the encryption (may increase for huge data).
  • Once the encryption finishes, Reboot your PC to incorporate the recent changes. 


That would be all! I hope you must now able to password-protect a folder or file in Windows 10. If you have any queries or suggestions, ping us in the comment section. 

Soni Aryan

Soni Aryan

Soni Kumari is a tech enthusiast known for her expertise in how-to type topics and Windows troubleshooting articles. She loves exploring how to do things or tweaks in Android, iPhone, and other operating systems.