Keeping a Password Protected Folder make your data and files in the folder safe . As there are many softwares through which you can lock a folder but I there are many disadvantages in those softwares . These softwares consume more RAM where as this batch script doesn't take much memory to execute . The software needs to get installed and then it is used , But in Batch file script a simple procedure is used. So lets get started.
Now navigate to that folder , open a text file in it. ( you can do this with right click--->New--->Text Document ).
Now copy the below script and paste it in the Text file
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%== UR_PASSWORD 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
Next change the Password "Ur Password" to your desired password and save the file as anything.bat ( like mylock.bat) .
Create a Password protected Folder
Follow the below steps to create a Password Protected folder .- First you need to create a Folder where you can host the files which are need to be protected .
Now navigate to that folder , open a text file in it. ( you can do this with right click--->New--->Text Document ).
Now copy the below script and paste it in the Text file
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%== UR_PASSWORD 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
Next change the Password "Ur Password" to your desired password and save the file as anything.bat ( like mylock.bat) .
- If the file is being saved then delete the text file which you have created .
- Now you need to Run the batch file .bat file , to Run it you need to double click on it .
- This batch file will create a Folder named Private . This the folder where you need to add the files and folders which are private or password protected .
- Once you have finished adding all the files and images etc into the Private Folder then Run Batch file anything.bat again ( Just Double click on the .bat File ) .
- Now a Black screen Command prompt window appears asking If you are sure you want to lock the folder . Now Press "Y" and hit enter to lock the folder .
- Now the Folder Private disappears and your folder is hidden or password protected .
- If you want to make the password protected folder Private a new windows pops asking to Enter password to Unlock Folder .
- Now enter the same password which you have kept above , once you have entered the password Private folder reappears .If you have entered a wrong password the the window terminates .