There are a variety of third-party software packages with which you can add a password to folders in Windows. However, it is also possible to add a password to a folder without any additional software.
Instead, you can set up a batch file that adds a password to the folder, which allows you to password protect folders without the need for third-party software in Windows XP, Vista, 7, 8.1 and 10. Read on to learn more.
1. Enter a folder where you want to create the folder with the password.
2. Right click to create a text document.
3. Then open the text document, and copy (Ctrl + C) and paste (Ctrl + V) the following code into it:
cls
@ECHO OFF
title Folder Private
if EXIST "HTG Locker" goto UNLOCK
if NOT EXIST Private goto MDLOCKER
:CONFIRM
echo Are you sure you 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 Private "HTG Locker"
attrib +h +s "HTG Locker"
echo Folder locked
goto End
:UNLOCK
echo Enter password to unlock folder
set/p "pass=>"
if NOT %pass%== PASSWORD_GOES_HERE goto FAIL
attrib -h -s "HTG Locker"
ren "HTG Locker" Private
echo Folder Unlocked successfully
goto End
:FAIL
echo Invalid password
goto end
:MDLOCKER
md Private
echo Private created successfully
goto End
:End
4. Save the document as locker.bat (you will have to select “All files” in the Notepad saving window to save the file as a .bat instead of .txt file). Which saves the document as a batch file, and can delete the original text file.
5. Note: the text PASSWORD_GOES_HERE must be changed with an appropriate password.
6. When you double-click the batch file to run it for the first time, a folder named “private” is created.
7. Double-click on the locker.bat file to confirm Y to hide the folder.
8. Double click will ask you for the password you entered in the text file instead of PASSWORD_GOES_HERE and then confirm again with Y, and the folder reappears.
Finished!