Lock Files and Folders in Windows Without Extra Software


We have previously written about a utility used to lock files and folders in Windows, How to Protect and Lock Folders in Windows. Here is a method for locking files and folders without having to install a third-party software program.

Download the following text file, which contains the code for the batch file:


Open the file in Notepad. Replace “type your password here” in the LockCode.bat file with the password you want to use to lock and unlock the protected files and folders. DO NOT forget this password. Save the file as LockCode.bat.

NOTE: We realize this seems unsecure to enter your password in plain text into a text file, but this will be discussed later.

Text of LockCode.bat file

You should now have two files: LockCode.txt and LockCode.bat. If you cannot tell which file is which because the file extensions are not displaying, select Folder Options from the Tools menu in either My Computer or Windows Explorer.

Selecting Folder Options from the Tools menu

On the Folder Options dialog box, click the View tab, scroll down to the Hide extensions for known file types option and uncheck the check box.

Showing extensions for known file types

Now you should be able to see the extensions for both files.

File extensions on the files

Double-click on the LockCode.bat file to create a new folder named Locker. The new folder is created in the same directory as the LockCode.bat file.

Locker folder created

Place any files and other folders you want to protect into this Locker folder. Double-click the LockCode.bat shortcut on the desktop again to lock the Locker folder. You are asked if you are sure if you want to lock the folder. Type a Y if you are sure you want to lock the folder. The folder disappears.

Confirmation of locking the Locker folder

To unlock the Locker folder again, double-click on the LockCode.bat file. You are asked to enter your password.

Enter password

The folder is available again.

To make this a more secure option for locking files and folders, once you have locked the Locker folder, open theLockCode.bat file in Notepad and remove your password. You may either leave it blank or enter a dummy password. Only when you are ready to unlock your files and folders, should you open the LockCode.bat file again and re-enter your password and save the file again.

Then, you can double-click on the LockCode.bat file to unlock the Locker folder. If you don’t take this precaution, anyone can open your LockCode.bat file and view your password.

To open a .bat file in Notepad, you must open Notepad first. If you double-click on the file like you would if you were opening a text file, the file runs instead of opens.

Once Notepad is open, select Open from the File menu. Select All Files from the Files of type drop-down list to be able to see the LockCode.bat file. Then, you can click Open to open the file.

Opening a batch file in Notepad

To protect your password, you can also delete the LockCode.bat file and create it again from the original LockCode.txt file when you need to unlock your files.

NOTE: The LockCode.bat file MUST be in the same directory where the Locker folder was created originally for this method of locking files and folders to work. [via Rakshit Khare’s Blog]

by Lori Kaufman


title Folder Locker
if EXIST “Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}” goto UNLOCK
echo Are you sure u 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.
ren Locker “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 folder
set/p “pass=>”
if NOT %pass%==type your password here goto FAIL
attrib -h -s “Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}”
ren “Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}” Locker
echo Folder Unlocked successfully
goto End
echo Invalid password
goto end
md Locker
echo Locker created successfully
goto End

This entry was posted in Uncategorized and tagged . Bookmark the permalink.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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