Protect a folder under Windows 10 with a password

protect folder windows 10
protect folder windows 10

Last updated: September 2, 2022

There is a very simple method to implement for protect a file on a computer under Windows 10, without installing any software.

To do this, you just have to follow the different steps of this tutorial.

Protect a folder Windows 10 with a password

1. Creating a batch command file

In the folder where you want to create a protected directory, create a text file.
You will name this file whatever you want, only the extension [. Beat] is necessary for the operation to function properly.
Un file [.bat] is a file that will carry out system commands one after the other in batch mode (hence its name batch file).

Password folder protection under WIndows 10

2. The commands of the batch file

Select, then copy and paste the following command lines into the [protect.bat] file.

class
@ ECHO OFF
title Private Folder
if EXIST “Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}” goto UNLOCK
if NOT EXIST Private goto MDLOCKER
: CONFIRM
echo Are you sure you want to block files Y=Yes N=No(Y/N)
set/p “cho=>”
if %cho%==O goto LOCK
if %cho%==o 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 Secure Folder
goto End
Unlock
echo Enter password to unlock
set/p “pass=>”
if NOT %pass%== password go to FAIL
attrib -h -s “Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}”
ren « Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D} » Private
echo Folder unlocked
goto End
: FAIL
echo Incorrect password
goto end
: MDLOCKER
md Private
echo Folder created
goto End
: End

This batch script can be customized by changing the [Private] and [password] variables in the source file (noted in blue in the previous code).

Batch file operating mode

During the first launch of this batch (protect.bat), it will create a folder named [Private]. This folder will be created in the directory where the batch (file protect.bat) is present.

In order to protect files From the eyes of other users of your computer, all you have to do is drop the files to protect in the [Private] folder.

For subsequent launches when the [Private] folder is invisible, launching the protect.bat batch will make the [Private] folder visible by entering the password (password in the example).
Otherwise, when the [Private] folder is visible, launching the protect.bat batch will make the folder invisible.

Limitations of the method

This method is very simple to implement and effective for family use. On the other hand, there are limits to this method.

The password is contained in plain text in the protect.bat file and is therefore visible to anyone who is a little geek. This can be improved by modifying the characteristics of the [protect.bat] file.

By right-clicking on the [protect.bat] file, choose [Properties] then check [Hidden file].

But here again, a somewhat informed person will be able to see the [Protect.bat] file by checking the [Hidden elements] option in the [View] tab of the file explorer.