Last updated: September 2, 2022
There is a very simple method to implement for protect a file on a computer running Windows 10, without installing any software.
To do this, you just have to follow the different steps of this tutorial.
Protect a Windows 10 folder with a password
1. Creation of 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 which will carry out system commands one after the other in batch mode (hence its batch file name).

2. The commands of the batch file
Select, then copy and paste the following command lines into the [protect.bat] file.
@ 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
assign -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. However, 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 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.
I know how to write in dos and create *.BAT files. So others open my proof and modify it.
No protection by this means.
Sorry to contradict you.
cordially
Bonsoir
I tried your method and my faith it works well especially with a DDE or a USB key, I juggle between W1O and macOS…good for me to find a way to read my file on both operating systems!!!!
well, by analyzing the code, I realize that you are comparing if NOT %pass%== with a hard word. So it seems that the password to put is instead of the word PASSWORD just on this line.
The problem in your tutorial is that you say that the variables are in blue when this is not the case..
Hello, Like Kablan I wonder what private variable you are talking about since in no case this variable is defined. We do have a comparison of the variable on the <> line, but there is no password= line so there is no risk of unlocking anything.
Hello,
On my Windows 10 Home, it doesn't work.
The batch stops after the first question (yes / no).
An idea?
Goods.
Hi, thank you for this rich new innovation. But I didn't quite understand the notion of modifying private variable