How to Place a Password Lock on a File or Folder in Windows

Spread the love

One of the biggest issues with sharing your computer with others is that it is difficult to keep any files private. Fortunately, Windows allows you to password-protect files or folders so that only you and the people you trust can access them. This tutorial shows how to set up a password for a file or folder on your PC to limit access to it.

Good to know: give your Windows Terminal a bit more personality with these themes.

Content

How to Protect a File or Folder Using Encryption

On your Windows PC, find the file or folder you want to protect from prying eyes. Right-click it, and select Show more options -> Properties. Click the Advanced button in the new window.

Tick the option to Encrypt contents for secure data and press OK. Click on Apply in the next window.

Windows will ask whether you want to apply these changes to the entire folder, subfolder, and files. Agree to this just to be on the safe side of things.

A pop-up will ask you to back up the encryption key. You will need this if you lose access to your file or folders. If you don’t see one, press Advanced again in the Properties window.

Click Details.

Click on your Windows username, and press the Back up keys button.

Press Next in the new window that appears. Make sure Personal Information Exchange is enabled, as well as Include all certificates in the certificate path if possible and Enable certificate privacy. Press Next.

Tick the Password option, and type in your password. Click Next.

Add the location of the backup, and hit Next -> Finish.

When you go back to your file and/or folder, you’ll notice a small yellow lock icon on it, indicating that it is encrypted.

The problem with this method is that it is tied to your Windows account. If you’re logged in to your account and trying to access the file or folder, the system will automatically decrypt them for you. This means if other people are using your profile, they will have unrestricted access, despite the encryption. Yet, users who are logged in through another account on your PC will not.

To ensure your files and folders are fully protected, consider implementing one of the following methods.

Tip: can’t access a folder in Windows due to a permission error? Read on to learn how to proceed.

How to Password Protect a File or Folder Using BAT File

Create a new folder on your computer, and add a text document inside the folder.

Copy and paste the following code into the text document:

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%== mypassword 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

In the 32nd line of the code, change the word “mypassword” to whatever password you wish to use for the folder. Make sure to leave a single space before and after the password.

Click File -> Save As in the menu at the top.

In the new window that opens, save the file type as All Files, and change the name of the file to “Lock” or any other name you wish, but make sure to add the extension .BAT at the end of the file name. Hit Save and exit the text document.

Double-click the new batch file inside the folder, revealing a new folder called Locker. Drag and drop all the files you wish to keep private, except for the .BAT file, inside this new secret folder.

Double-click on the .BAT file, and a pop-up will ask if you are sure you wish to lock the folder. Type Y in uppercase, and hit Enter. The folder will lock and disappear.

To make the folder reappear, find the .BAT file again, and double-click it. Type in the password you created in the new window, and hit Enter.

The hidden folder containing your private files will appear. Access the files just as you normally would.

When you are done using the files, go back to the previous folder, and double-click on the .BAT file. The program will again ask if you wish to lock the folder. Type uppercase Y, and hit Enter to lock the folder.

Repeat this process as long as you wish to keep using the password-protected folder.

Another solution for keeping only select files or folders private is to set up OneDrive’s Personal Vault in Windows. Since OneDrive is baked into the operating system, it’s a convenient option.

How to Password Protect a Specific App

If the method above sounds a bit too complicated for you, this solution may be a better option for you. Install an app like Folder Lock, and instruct it to secure select apps or folders.

Download the free Folder Lock app, and install it on your device. The first time you launch it, you must set a master password.

Start adding apps to the vault. Press the Add Items to Lock button, and select whether you want to add a file, folder, or even a drive. To secure apps, try adding their executable files to Folder Lock. Once you’ve added all of the apps you wish to keep secure, exit the program.

When you try accessing a shortcut to one of the apps you’ve added to Folder Lock, you’ll get an error that says something is wrong with the shortcut. At the same time, the file or folder will go missing from its original location.

If you wish to restore functionality to the app, open Folder Lock again, and type the master password.

Click the executable in question, and select the Unlock items button.

Folder Lock is free to use for a total of 22 days. To continue using it, subscribe to a paid plan.

FYI: check out how to change the default save location for file types in Windows.

How to Password Protect an Entire Hard Drive

In some cases, you may want to protect an entire hard drive from unauthorized access. Fortunately, Windows comes with BitLocker, a feature that allows you to encrypt hard drives. You will need a password to access the drive afterward.

To enable BitLocker, open File Manager, and right-click on the hard drive you want to protect under This PC. Select Show more options -> Turn on BitLocker.

Check the option to Use a password to unlock the drive, type in your password below, then press Next.

Windows will ask how you want to back up your recovery key. Make your choice, then click Next.

Choose where you want BitLocker to encrypt your whole drive, or only the used disk space. Depending on whether you’re looking to encrypt a new drive or one that’s already in use, make your selection, and press Next.

Select the encryption mode. Choose the first option if you’re using a device with a fixed drive. If you’re looking to move the drive around, tick the second.

Press the Start encrypting button.

Restart your PC.

Once you log back in and navigate to the drive you’ve encrypted, a small yellow lock icon will be overlaying it, indicating encryption.

Anyone who wants to access the drive will need to provide the password.

If you want to go the extra mile in safeguarding your sensitive information, check out our guide that details the best Windows security options to enable free protection. It may also be useful to know how to protect yourself against password crackers.

Image credit: Freepik. All screenshots by Alexandra Arici.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Sign up for all newsletters.
By signing up, you agree to our Privacy Policy and European users agree to the data transfer policy. We will not share your data and you can unsubscribe at any time. Subscribe


Alexandra Arici
Staff Writer

Alexandra is passionate about mobile tech and can be often found fiddling with a smartphone from some obscure company. She kick-started her career in tech journalism in 2013, after working a few years as a middle-school teacher. Constantly driven by curiosity, Alexandra likes to know how things work and to share that knowledge with everyone.

Leave a comment