How do I Check a Flash Drive for a Virus or Trojan Horse?

By James Rutter

Before you open your USB drives, check them for viruses and Trojans.
i computer virus image by Marina Bartel from Fotolia.com

USB flash drives contain flash memory storage, and connect to a computer or other device via a USB port. Like a computer's hard drive or a piece of software, these drives can become infected with Trojan horses--malware designed to grant a third-party access to your computer and information--or viruses designed to use flash drives as a tool to infect computers. You can detect viruses, Trojans and other forms of malware hiding in your USB flash drive by using the command prompt.

Step 1

Press the "Shift" key as you insert the USB drive into your computer. Holding down "Shift" will keep the computer from auto-playing the device. Click "Cancel" to exit the auto-run if you do not hold "Shift" down long enough and the auto-play function starts.

Step 2

Open the Windows Command Prompt by clicking "Start" and then highlighting and clicking "Run." Type "cmd" (without the quotes) in the text box, and press "Enter." If you use Windows Vista, click the Windows icon, then type "cmd" in the "Search" box and hit "Enter."

Step 3

Switch the Command Prompt to your USB flash drive by typing the letter of the drive followed by a colon--for example, "F:" without the quotes--and pressing "Enter." You can locate the letter that Windows assigns to your flash drive by clicking "Start," then highlighting and clicking "My Computer."

Step 4

List the directory of files on your flash drive by typing "dir/w/o/a/p" (no quotes) into the Command Prompt and pressing "Enter." This line will tell your USB drive to compile and display a list of all files.

Step 5

Locate common viruses, Trojan horses, or malicious files in the list. Two of the most commonly reported pieces of USB malware will appear as "Autorun.inf" or "smss.exe" (both without the quotes). Unless you are using your USB to transfer a program from one computer to another, you should be suspicious of any executable file--file types ending ".exe"--that appears in your flash drive's directory. Also, as a general rule of thumb, if you see any files on your USB drive other than ones you have personally stored on it, your flash drive is infected.

Step 6

Set your USB drive to show all files so that you can delete them. Copy and paste "attrib -r -a -s -h ." (without the quotes) into the command prompt and press "Enter." These letters stand for "Read Only, Archive, System and Hidden File," and entering this line will tell your USB file to recognize them.

Step 7

Delete any viruses, Trojan horses, malware and suspicious files. Type "del" (no quotes) followed by a space and then the name of the file; for instance, "del smss.exe". Press "Enter" to delete that file from your USB flash drive.

×