How to lock a folder or file in Windows

As I explained before locking a folder or file can be ridiculously easy to hack or may require software. One easy way that can be used to lock a folder or file can be used for those that do not know the method. If they know it, they can easily hack it, or in this case use it, to open the folder or file. If you would like an ever harder to hack way of locking a folder or file you can go to the bottom.


Start by creating a folder like the one in the picture provided, such as "Fonts" without the quotes. Create it in a simple directory, such as C:.

Now you can add a text file, or something similar to show the effects of a locked folder. To lock it we use a method of redirecting the folder to show the contents of the Control Panel. It will simply change the icon to


show that of the Control Panel, and when clicked on it will show the elements and shortcuts in the Control Panel instead of the files you have put inside of the actual folder. The file to 'lock' the folder will be called "loc.bat" with quotes. Go to the same directory as the file you have created, such as C:, but not in the folder, and right click. Go to "New" then "Text Document." Copy and Paste the following into it and replace the words "Fonts" with the name of your created folder:

ren Fonts Fonts.{21EC2020-3AEA-1069-A2DD-08002B30309D}

Save it as "loc.bat" with the quotes and, if clicked on, should change your folder's icon to that of the Control Panel. If you click on it, it should also load the contents of the Control Panel and not the contents of your folder. Now, since you probably want to open the folder with the correct contents we will create the file that changes the icon back to the regular folder icon and redirects you, when clicked, to the correct location and with the correct contents. Create a new "Text Document" in the same directory as the folder and the "loc.bat" file and copy and paste the following into it, but change the words "Fonts" with the name of your folder:

ren Fonts.{21EC2020-3AEA-1069-A2DD-08002B30309D} Fonts

Save it as "key.bat" with the quotes. Now if you have clicked the "loc.bat" file previously and it is still on the Control Panel icon, if you click on the "key.bat" file, you should be able to see the icon changed and the contents correct again.

Alternative Method

As I said previously, you can use another method that is more secure and difficult to hack. This method uses the Command Prompt, so open the Command Prompt by going to "Start" and "Run" and typing "cmd" without quotes in the box. Click "Ok." You need to create a folder to protect, so go to a directory, such as C:, and right click. Go to "New" and "Folder." Name it anything with one word, preferably. Now create a file by right clicking, while inside the folder, and go to "New," and "Text Document." Name it something with preferably one word. Go back to the command prompt and enter the following:

cd C:\Test

Replace the "C:\" with the directory you are using and replace "Test" with the folder you created. Now you are located inside the C:\Test folder. To secure and hide the file you created type the following, but replace the word "filename" with the name of the file you created with ".txt" at the end of the filename, not in quotes:

attrib filename +s +h

Now, if you load the folder you should not be able to see the file you created.

Examples

Pictures provided from http://www.online-tech-tips.com/computer-tips/how-to-create-a-secured-and-locked-folder-in-windows-xp/ and http://www.online-tech-tips.com/computer-tips/another-way-to-hide-files-and-folders-in-windows-xp/.