How to Lock a Folder Using Notepad

Sometimes, there is a need for hiding some data files in a computer system… Moreover, to “lock” a folder with data inside it.
Here, I’m going to share a nice and handy trick (for Windows OS) to do the same. It is actually a code snippet for a batch file that can be composed on Notepad easily. Technically, this is a way to change the folder’s attributes for “hiding” it and then changing them back to normal when needed.
I have compiled two ways of doing it, the ones I find convenient and working…

The I Way
Open ‘Notepad’ and put down the following code:

title folder-lock
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
if NOT EXIST MyFolder goto MDMyFolder
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.
ren MyFolder "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
echo Folder locked
goto End
echo Enter password to Unlock Your Secure Folder
set/p "pass=>"
if NOT %pass%== wallofwonders goto FAIL
attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" MyFolder
echo Folder unlocked successfully
goto End
echo Invalid password
goto end
md MyFolder
echo MyFolder created successfully
goto End

Then click on “Save As” option in the file menu and save it as “AnyName.bat”. Here, the extension ‘.bat’ is very important. The above code hence generates a batch file which is our “key” to the lock.

When you first click on the file, it will automatically create a new folder named “MyFolder” for locking purposes, if any folder with the same name is not present in the same directory/place. (If there is, and you don’t want to lock that one, move it or the batch file to some other place.)
The next time you click the file, it will ask you weather you want to lock “MyFolder”. Type ‘Y’ and press “Enter” for a yes… Here, the “MyFolder” goes hidden (say, locked).
And now, when you will open the batch file again, it will ask for a password to open (unhide) the folder. The password for above mentioned file is “wallofwonders“, which you may edit in the above code. See that “MyFolder” is now unlocked (visible).

The II Way
In this method, we will create two separate batch files – one to lock the folder and another to be used as a “key” for the already locked folder; And there will be no use of passwords.
Note that this one will not create a new folder for you like the above, so please place a folder named exactly “MyFolder” in the same directory/place along with the file you are now going to create…

Open ‘Notepad’ and paste the following code:

ren MyFolder MyFolder.{21EC2020-3AEA-1069-A2DD-08002B30309D}
attrib +h +s "MyFolder.{21EC2020-3AEA-1069-A2DD-08002B30309D}"

And save it as “Locker.bat”, where the extension ‘.bat’ is important.
Make another file in ‘Notepad’ with the following code:

attrib -h -s "MyFolder.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
ren MyFolder.{21EC2020-3AEA-1069-A2DD-08002B30309D} MyFolder

Save it as “Key.bat”.

Folder Locking Files

Now when you will click on “Locker” file, the folder “MyFolder” becomes hidden (locked) and to open it, just run the “Key” file.

Important notes

  • This is a way of simply hiding and unhiding the folder.
  • Note that the password can be viewed by someone who edits the batch file and understands its programming structure. I advise you to move the batch file to some safe location after locking the folder, and to move it back to the same directory whenever you want to open the folder.
  • The folder “MyFolder” (or any other concerned), and the related files work only when present in the same directory.

4 thoughts on “How to Lock a Folder Using Notepad

    1. Yes, of course. It’s completely normal.
      You can not learn the deepest about computers until you play with such “geeky” settings! In fact, this is the first step.

Leave a Reply →

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.