As you all know most of the viruses which spread through Flash drives use the autorun.inf file to auto execute it.
You can do a simple registry tweak or you can use software like autorun eater to block the execution of the instructions on this file. Here I’m not going to describe that. What I’m going to explain here is how to stop your flash drive becomes a carrier for viruses.
In here I`m using a feature of windows which is rarely noted by users
You can`t create a file and a folder which has the same name in the same location (directory).
Ex. You can`t create a file called isuru.txt while having a folder called isuru.txt in the same directory.
So what you have to do is create a read-only folder called autorun.inf in the root of your flash drive.
What if the virus is smart enough to delete the folder autorun.inf?
For that let’s do a small trick.
MS-DOS Device Driver Names Cannot be Used as File Names
You can use this feature to prevent the deletion of the autorun.inf folder
What you have to do is create folder called CON inside the autorun.inf folder using Linux or by executing the following commands in command prompt
(x is your drive flash drive)
x:
cd autorun.inf
md .\CON\.
The Folder CON cannot be deleted from windows. Therefore you are not allowed to delete autorun.inf folder.
This will work for most of the viruses. But I can’t guarantee this will work for all the viruses.
I wrote a simple batch file to do all above tasks. You can copy this file to root of your flash drive and execute it. Get it from here.