Hi guys, today I’m going to share something many of us actually need. Most of the time, we need to lock our private folders which may include password text files, business data, media, and much more, which we don’t want other sneaky people to have a look into.

But if you are a Windows guy, this can be tricky, as there is no out-of-the-box functionality available in windows to do this. To accomplish such a task, we may download some unknown software from the internet, which often turns out to be malware.

So, to avoid this, you can use this simple batch program, which can make a secure folder, that can be locked and unlocked as and when needed.

For better understanding, check out this video :)

Now, as our objective is clear, you can proceed to follow the steps below:

Copy this code and paste it into NotePad

cls
@ECHO OFF
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
if NOT EXIST Secure goto MDSecure
:CONFIRM
echo Are you sure to lock this 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 Secure "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
echo Folder locked
goto End
:UNLOCK
echo Enter password to Unlock Your Secure Folder
set/p "pass=>"
if NOT %pass%== <ENTER_YOUR_REQUIRED_PASSWORD> goto FAIL
attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" Secure
echo Folder Unlocked successfully
goto End
:FAIL
echo Invalid password
goto UNLOCK
:MDSecure
md Secure
echo Secure created successfully
goto End
:End

Add your desired password

This can be tricky but is really easy, just find <ENTER_YOUR_REQUIRED_PASSWORD> in the file (with Ctrl+F key combination) and replace this whole thing with what you want as your password. For example, if you change that line to:

if NOT %pass%==1234 goto FAIL

This line sets the password to 1234. You can change it to your desired value.

Save the file as locker.bat

Be sure to change Save as type to All Files and the extension of the file should be .bat and save it at your desired location.

save

Double click the locker.bat file

This will make a folder named Secure beside the locker.bat file.

Move the files which you need to lock to this new Secure folder.

Double click the locker.bat file again

This time, you will be asked if you want to lock the folder or not. Enter Y and press enter.

The Secure folder will be hidden now. Be assured that the folder can’t be viewed even when the View Hidden Files attribute is enabled in File Explorer


Congrats! You have secured your folder. Now, to access the files again, double click the locker.bat file again, and enter the password you set previously. This will make the Secure folder pop up again, you can do your desired changes and lock the folder again.

I hope this article helped you. Thanks for reading so far :)


Join discussions at our discord server >
Did you learn something new today? Spread the word!

Contribute to the Genics Blog!

Genics Blog is a purely open source publication. Authors at Genics post highly resourceful content on varied topics relevant to the developer community. Join us and start publishing today!

Contribute

Related content