Windows doesn’t have a “password lock” feature for folders, but there are ways you can protect your private files and add an extra layer of security. If you need to keep a folder private and password protected in Windows, there is a method you can use to lock files or password-protect a folder on your Windows PC. Here is an effective option you can try.
Lock the Folder Using a Batch File
If you don’t want to use any third-party applications and programs then creating a batch file can be a better way to lock the folder with a password. Here’s how to do it.
- Find or create the folder you want to lock and open it.
- Right-click on an empty space in the File Explorer window and select New from Text Document.
- Copy and paste the code below into the text document.
@ECHO OFF
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
if NOT EXIST Private goto MDPrivate
:CONFIRM
echo Are you sure to lock this 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 Private "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 Your Secure 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}" Private
echo Folder Unlocked successfully
goto End
:FAIL
echo Invalid password
goto end
:MDPrivate
md Private
echo Private created successfully
goto End
:End
- Replace your_password in the text file with your password. This is to replace your_password with your password in the line if NOT “%pass%==your_password” goto FAIL.
- Go to File in the menu and select Save as.
- Give the file a name and add the .bat extension at the end.
- Select All Files from the Save as type dropdown menu and click Save.
- Double-click to run the BAT file. This will create a new folder named Private.
- Move all the files and folders you want to lock to the Private folder.
- Once you have moved all the files and folders to the Private folder, double-click on the BAT file again.
- Command Prompt window will open, enter Y in it, and press the Enter button.
Now your folder will be hidden. To access the folder later, double-click on the BAT file. It will ask you to enter a password, enter the password you entered while setting up the batch file. If you enter the correct password, the private folder will be visible again.
Note: The BAT file created to lock the folder can be modified. The person who knows this trick can change the password in this file.