Step # 1-Create a new text document
First of all,
⇒ Create a new folder and name it whatever you would like.
⇒ Open the folder and create a text document.
Step # 2–Paste the code in the file
⇒ Once the text document is created,
⇒ Open the text file you just created by double-clicking it and copy/paste in the following text:
title Folder Private
if EXIST “HTG Locker” goto UNLOCK
if NOT EXIST Private goto MDLOCKER
echo Are you sure you want to lock the folder(Y/N)
set/p “cho=(more than)”
if %cho%==Y goto LOCK
if %cho%==y goto LOCK
if %cho%==n goto END
if %cho%==N goto END
echo Invalid choice.
ren Private “HTG Locker”
attrib +h +s “HTG Locker”
echo Folder locked
echo Enter password to unlock folder
set/p “pass=(more than)”
if NOT %pass%== PASSWORD_GOES_HERE goto FAIL
attrib -h -s “HTG Locker”
ren “HTG Locker” Private
echo Folder Unlocked successfully
echo Invalid password
echo Private created successfully
Step # 3 –Rename the text document
⇒ In the above code, replace the key PASSWORD_GOES_HERE with the password you want to use to unlock the folder. For example if you want the password to be 123456, the line should look like:
if NOT %pass%== 123456 goto FAIL
⇒ After you set the password to folder in Windows 7 save the file and close it. Rename the document to “locker.bat“. Make sure it does not include “.txt”.
⇒ So now your Complete File Name will be locker.bat. To do this, make sure to change the Save as type: to All Files (*.*).
⇒ Double click the locker.bat file and there will now be a new folder named Private where you can Put your Content
Step # 4 –Enter password
⇒ This time you will be asked if you want to lock the folder, press the “y” key and then hit “enter”.
⇒ The private folder will disappear and if you try to run the batch file again, the password protected folder will ask you for the password.
⇒ To check whether it works, enter an incorrect password and see that it will not open the file. Once the correct password is entered the “private” folder will be accessible.
Checkout The Video Below For Demo