loading

Everyone of us stumbled across situation where we wanted to make some files invisible to friends, family or anyone else. We all found some applications that encrypt files but they are either useless or have to be paid for.

This instructable will teach you to hide your files even from highest sysadmins on any windows machine. What I will teach you is to tailor a simple .bat script that will make it impossible for anyone to come across your files.

Maybe I am exaggerating a bit but it will hide your files from anyone who isn't expecting them or doesn't have advanced windows knowledge... I mean no one found found all my torrents and I work in an IT company...

Step 1: Lock.bat -tweaking Vol. 1

<style type="text/css">span {
	font-family: Lucida Console;
	font-size: 10.0pt;
	color: rgb(0,0,0);
}
*.sc0 {
}
*.sc1 {
	color: rgb(0,128,0);
}
*.sc2 {
	font-weight: bold;
	color: rgb(0,0,255);
}
*.sc3 {
	font-weight: bold;
	color: rgb(255,0,0);
	background: rgb(255,255,128);
}
*.sc4 {
	color: rgb(255,0,255);
}
*.sc5 {
	color: rgb(0,128,255);
}
*.sc6 {
	font-weight: bold;
	color: rgb(255,128,0);
	background: rgb(252,255,240);
}
*.sc7 {
	font-weight: bold;
	color: rgb(255,0,0);
}
</style>


<div style="float: left;white-space: pre;line-height: 1;"><span class="sc4">@</span><span class="sc2">echo</span><span class="sc0"> off
</span><span class="sc5">color</span><span class="sc0"> a
</span><span class="sc5">title</span><span class="sc0"> File Locker
</span><span class="sc2">echo</span><span class="sc0"> </span><span class="sc6">%cd%</span><span class="sc0">
</span><span class="sc1">::remove :: from next line after you finish tweaking program
::attrib +s +r Lock.bat
</span><span class="sc2">pause</span><span class="sc0">

</span><span class="sc1">::polls command
</span><span class="sc2">cls</span><span class="sc0">
</span><span class="sc2">set</span><span class="sc0"> /p pwd</span><span class="sc7">=</span><span class="sc0"> Password:
</span><span class="sc2">if</span><span class="sc0"> </span><span class="sc6">%pwd%</span><span class="sc0"> </span><span class="sc7">==</span><span class="sc5"> unlock</span><span class="sc2"> goto</span><span class="sc0"> unlock
</span><span class="sc2">if</span><span class="sc0"> </span><span class="sc6">%pwd%</span><span class="sc0"> </span><span class="sc7">==</span><span class="sc5"> lock</span><span class="sc2"> goto</span><span class="sc0"> lock
</span><span class="sc2">if</span><span class="sc0"> </span><span class="sc6">%pwd%</span><span class="sc0"> </span><span class="sc7">==</span><span class="sc5"> 101</span><span class="sc2"> goto</span><span class="sc0"> emergency


</span><span class="sc3">:exit
</span><span class="sc1">::if no valid command is entered, files get locked
</span><span class="sc2">cls</span><span class="sc0">
</span><span class="sc2">cd</span><span class="sc0"> C:\Users\ptkrf\Desktop\Just Stuff\
</span><span class="sc5">attrib</span><span class="sc0"> </span><span class="sc7">+</span><span class="sc0">h </span><span class="sc7">+</span><span class="sc0">s </span><span class="sc7">+</span><span class="sc0">r </span><span class="sc7">*</span><span class="sc0">.mp4

</span><span class="sc2">cls</span><span class="sc0">
</span><span class="sc2">echo</span><span class="sc0"> Access denied...
</span><span class="sc5">ping</span><span class="sc0"> localhost - 2 </span><span class="sc7">></span><span class="sc2">nul</span><span class="sc0">
</span><span class="sc2">exit</span><span class="sc0">


</span><span class="sc3">:unlock
</span><span class="sc1">::unlocks files
</span><span class="sc2">cls</span><span class="sc0">
</span><span class="sc2">cd</span><span class="sc0"> C:\Users\ptkrf\Desktop\Just Stuff\
</span><span class="sc5">attrib</span><span class="sc0"> -s -h -r </span><span class="sc7">*</span><span class="sc0">.mp4

</span><span class="sc2">cls</span><span class="sc0">
</span><span class="sc2">echo</span><span class="sc0"> </span><span class="sc6">%cd%</span><span class="sc0">
</span><span class="sc2">echo</span><span class="sc0">.
</span><span class="sc2">echo</span><span class="sc0"> Files Unlocked...
</span><span class="sc5">ping</span><span class="sc0"> localhost -n 2 </span><span class="sc7">></span><span class="sc2">nul</span><span class="sc0">
</span><span class="sc2">exit</span><span class="sc0">


</span><span class="sc3">:lock
</span><span class="sc1">::locks files
</span><span class="sc2">cls</span><span class="sc0">
</span><span class="sc2">cd</span><span class="sc0"> C:\Users\ptkrf\Desktop\Just Stuff\
</span><span class="sc5">attrib</span><span class="sc0"> </span><span class="sc7">+</span><span class="sc0">h </span><span class="sc7">+</span><span class="sc0">s </span><span class="sc7">*</span><span class="sc0">.mp4

</span><span class="sc2">cls</span><span class="sc0">
</span><span class="sc2">echo</span><span class="sc0"> Success.
</span><span class="sc5">ping</span><span class="sc0"> localhost -n 2 </span><span class="sc7">></span><span class="sc2">nul</span><span class="sc0">
</span><span class="sc2">exit</span><span class="sc0">


</span><span class="sc3">:emergency
</span><span class="sc1">::deletes files
</span><span class="sc2">cls</span><span class="sc0">
</span><span class="sc2">set</span><span class="sc0"> /p e</span><span class="sc7">=</span><span class="sc0"> Awaiting confirmation. (Y/N):
</span><span class="sc2">if</span><span class="sc0"> </span><span class="sc6">%e%</span><span class="sc0"> </span><span class="sc7">==</span><span class="sc5"> Y</span><span class="sc2"> goto</span><span class="sc0"> Y
</span><span class="sc2">if</span><span class="sc0"> </span><span class="sc6">%e%</span><span class="sc0"> </span><span class="sc7">==</span><span class="sc5"> y</span><span class="sc2"> goto</span><span class="sc0"> Y
</span><span class="sc2">exit</span><span class="sc0">

</span><span class="sc3">:Y
</span><span class="sc1">::confirm delete
</span><span class="sc2">cd</span><span class="sc0"> C:\Users\ptkrf\Desktop\Just Stuff\
</span><span class="sc5">attrib</span><span class="sc0"> -r -s </span><span class="sc7">*</span><span class="sc0">.mp4
</span><span class="sc2">del</span><span class="sc0"> /q </span><span class="sc7">*</span><span class="sc0">.mp4
</span><span class="sc2">exit</span></div>

Above is the code I will teach you to adapt to your needs. The first thing you want to do is download code (see attached files at the end of this step).

Now open it in Notepad or any other basic text editor. Note that it must not be rich text editor such as MS Word. If you want to understand how Lock.bat works, I recommend using Notepad++, a very powerful text editor.

In this step I will only tell what to tweak for this program to work for you but will go more in depth in next step. Start by replacing all file destinations with desired ones. That means you must replace every

<span class="sc0"> C:\Users\ptkrf\Desktop\Just Stuff\</span>
with absolute path to your folder with files you want to hide. The best way to do this is if you navigate to folder containing your files and copy address. Then open open Lock.bat in notepad, hit ctrl+f go to replace tab, paste C:\Users\ptkrf\Desktop\Just Stuff\ in find what box, paste your path in replace with box and click replace all. This will replace every file path in Lock.bat with your file path.

Next step is to decide what you wnat to hide because to be honest nothing is more suspicious that an empty folder. At the moment Lock.bat only affects any .mp4 files.what this means is that I can have a bunch of random files in same folder and no one will even think there could be any files hidden from them.

You can choose to hide files of same file type (they share same suffix), contain specified keyword in their name or all in folder. If you want to hide every file, just replace every *.mp4 from Lock.bat with *.*. Like this:

<span class="sc5">attrib</span><span class="sc0"> </span><span class="sc7">+</span><span class="sc0">h </span><span class="sc7">+</span><span class="sc0">s </span><span class="sc7">+</span><span class="sc0">r </span><span class="sc7">*</span><span class="sc0">.mp4</span>
would become
<span class="sc5">attrib</span><span class="sc0"> </span><span class="sc7">+</span><span class="sc0">h </span><span class="sc7">+</span><span class="sc0">s </span><span class="sc7">+</span><span class="sc0">r </span><span class="sc7">*</span><span class="sc0">.</span><span class="sc7">*</span>
Easiest way to do this is to find and replace every *.mp4 with *.* as you did with paths.

To hide all files of one file type, you would do the same thing only that you would replace *.mp4 with *.yourSuffix.

If you want to hide more than one file type, you must copy every line beginning with attrib command and duplicate it. Then change suffixes to fit your needs. For example if you wanted to hide all .doc and .gif files, you would change Lock.bat as shown in example below.

<span class="sc5">attrib</span><span class="sc0"> </span><span class="sc7">+</span><span class="sc0">h </span><span class="sc7">+</span><span class="sc0">s </span><span class="sc7">+</span><span class="sc0">r </span><span class="sc7">*</span><span class="sc0">.mp4</span>
would become
<span class="sc5">attrib</span><span class="sc0"> </span><span class="sc7">+</span><span class="sc0">h </span><span class="sc7">+</span><span class="sc0">s </span><span class="sc7">+</span><span class="sc0">r </span><span class="sc7">*</span><span class="sc0">.doc</span>
<span class="sc5">attrib</span><span class="sc0"> </span><span class="sc7">+</span><span class="sc0">h </span><span class="sc7">+</span><span class="sc0">s </span><span class="sc7">+</span><span class="sc0">r </span><span class="sc7">*</span><span class="sc0">.gif</span>
Do note however that example was for one line only. You have to change all 4 lines beginning with attrib. Failure to do so will result on malfunctioning program. Leave the one beginning with ::attrib alone for now. I'll get to it later.

Step 2: Lock.bat -tweaking Vol. 2

And what if you wanted to hide all files containing a specific keyword? That will be a bit trickier if you don't understand how windows search feature works and that's why I wrote this short rundown of what it is.

Symbol "*" stands for anything (which may also be just nothing). If you search for *.mp4 you are actually telling windows to find all files that have anything in their name but have suffix mp4. If you wanted to find documents starting with xxx and suffix mp4, you'd tell windows to look for xxx*.mp4. Windows would understand that as "look for files that are named "xxx[anything].mp4" and return files like "xxx cute ducklings.mp4", "xxx.mp4", etc. If you wanted to find GIFs that contain word cat, you'd tell windows to search for *cat*.gif. That would give you files such as "naughty cat caught on tape.gif", "cat.gif", etc. Note that keyword is case sensitive (cat is not the same as cAt). There are many more things you could to with this but you won't need any more for what I am teaching you to do today.

Now that you know the basics of windows search with *, I can tell you how to modify Lock.bat to hide files containing a keyword. To do that, you will have to replace *.mp4 with *keyword* or with any search string as learned in previous paragraph. If you wanted to hide all files containing keyword confidential, you would do it as shown in example below.

attrib+h +s +r *.mp4
would become
attrib+h +s +r *confidential*
Just like with hiding multiple file types, you can also hide files containing one or more different keywords by adding more lines and you can combine hiding files with keyword and file type. In this "ultimate" example I will show you how to modify Lock.bat to hide any gif file that contains word cat, all JPGs and files containing kitten in their name (just in case you need to hide how obsessed with cats you are :)
attrib+h +s +r *.mp4
would become
attrib+h +s +r *cat*.gifattrib+h +s +r *.jpgattrib+h +s +r *kitten*
I will remind you again that you need to change all 4 lines beginning with attrib. and do not just copy what you see in this example in all 4 locations as that won't work. you need to copy and modify each line in Lock.bat separately as they are different.

Step 3: Lock.bat -usage

Now that you know how to tweak Lock.bat, you are ready to start using it.

You simply double click Lock.bat, click any key (as instructions say) and enter "password" which isn't really a password but a command. You can choose from following commands: lock, unlock and 101. First two are simple to understand - lock or unlock files. The third one is a bit special. In case of emergency you can delete all hidden files. If you enter 101 you will be prompted to confirm deletion which can be done by entering "y" (followed by pressing enter) in command window. Any other command will cancel deletion. If no valid command is entered, program will lock files and close.

Once you've tested all three commands and confirmed they work, you can open Lock.bat once again and edit one last line. Remove "::"from beginning of 6th line as shown in example below:

::attrib +s +r Lock.bat
must become
attrib+s +r Lock.bat

What that does is it ensures no you won't be able to accidentally remove this program after you run it first time (this line locks Lock.bat every time you run it). To modify it later on, you will need to open file's properties and uncheck "locked" box. If you know what you are doing or are going to change program a lot, I recommend skipping this step.

Step 4: Warnings

Try not to loose Lock.bat because it is a bit trickier to recover files that remain hidden after lock.bat is gone. To recover them, you will have to run cmd.exe (launch from start menu) and enter following commands in same order:

cd path to your files - same as you entered in 1st stepattrib -h -r -s *.*

This will reveal all files in specified directory. Another workaround would be to disable hiding protected system files. The reason I wouldn't be afraid of anyone abusing this method is that no one will know where to look for your stash and if you try to disable hiding protected system files, you get this warning which will likely bounce any one off.

Step 5: Coclusion

I sincerely hope this instructable wasn't too boring and geeky and that you will be able to use it I know some of you won't understand it all so please comment your questions and I will provide answers.

Like this 'ible if you liked it, subscribe for more and please vote for this instructable in contests.

Also because I know someone will bring it up in comments, yes, this .bat script doesn't really lock your files. It does better. If your parents/SO/boss finds you have locked files, you will have a hard time getting out of situation while safely hidden files are a lot safer.

And I would be lying If I said I came up with this idea completely on my own. If you want complicated version of program, you can take a look at this.

About This Instructable

525views

23favorites

License:

Bio: An engineer by trade, an artist by heart. Here to share my knowledge, ideas and methods.
More by ptkrf:Carving a Zucchini Pumpkin Glowing dog pedant Star Wars themed retro arcade game 
Add instructable to: