Remove a Virus From a Flash Drive

Due to their portability, USB devices are convenient vessels for spreading viruses. USB devices are vulnerable to two major types of viruses: the shortcut virus and the autorun virus. We will discuss how to remove each virus with anti-malware software and manually entered commands. Learn about the measures Windows is taking to protect your computer from the autorun virus.

Steps

Removing Shortcut Viruses

  1. Understand the shortcut virus. The shortcut virus comes in two forms. The first type of shortcut virus replaces your desktop folder and file icons with shortcut icons—the icon will either appear with an arrow in the lower left hand corner, the word “shortcut” in the title, and/or the extension “shortcut.exe.” The second type of shortcut virus affects your USB or pen drive. This form of the virus places all of the files on your USB into a hidden folder and produces a shortcut.exe file of your pen drive. Attempting to open these files will activate the virus and cause it to spread to your PC.[1]
  2. Remove the shortcut virus with antivirus software. If your USB is infected with the shortcut virus, you can remove the malicious bug with antivirus software. Select Start > My Computer. Right-click on the removable drive and select “Scan for Viruses.” Follow the provided instructions to remove the shortcut virus.
    • If you are using Windows RT 8.1 or newer, your computer comes with Windows Defender. You can use the program to scan for viruses. Launch Windows Defender and select Settings > Advanced. Check the box next to “Scan removable drives.” Every time you run a full scan, your USB drive will be checked for viruses.[2]
    • If your computer is not equipped with antivirus software, download a reputable anti-malware program.
    • You should only have one anti-malware application downloaded and running at a time.[3]
  3. Remove the shortcut virus with a command prompt. You can manually remove the virus from your flash drive within a command prompt window. To open the command prompt window, click “Start” and search for “cmd.” Right-click on the “cmd” or “Command Prompt Window” result and select “Run as Administrator.” In the command prompt window:
    • Type in your USB’s letter and hit Enter. To determine the drive’s letter, open “My Computer” and identify the letter listed next to the removable drive.
    • Type del *.lnk and hit Enter.
    • Type attrib -s -r -h *.* /s.d/l/ and then hit Enter.
    • Open your flash drive. All of your files should return to normal.
  4. Backup your files. After removing the virus from your drive, you may wish to reformat your thumb drive. Reformatting your USB drive will remove all existing data from the drive, providing you with a clean, virus-free device. Before you reformat your drive, backup all of the files on the USB. Scan through the items on your pen drive and delete any unfamiliar files and folders. Move all of the files from your USB to a folder on your desktop.[4]
  5. Reformat your drive. Click “Start” and type “cmd” into the search bar. Launch the “Command Prompt Window.” Type in the letter associated with the thumb drive and hit Enter. Type format /q /x [INSERT YOUR DRIVE’S LETTER]: and hit Enter.[4] Return all of the files to your USB.[5]

Removing Autorun Viruses

  1. Understand the autorun virus. Originally, when you inserted a USB drive into a port, the USB drive automatically opened. If your USB drive was infected, this process executed a file called autorun.inf, which housed the autorun virus. As a result, when the USB drive automatically opened, it would activate the autorun virus. USB devices are no longer opened automatically with Windows XP, Windows 7, Windows 8, and Windows 10, which in turn means that the autorun.inf file is no longer executed automatically. This measure protects your computer from the virus.[6]
  2. Scan the drive for a virus. If you are concerned about the integrity of your pen drive, scan your drive for viruses before use. Click Start > My Computer. Right-click on the removable drive and select “Scan for Viruses.” If a virus is detected, follow the provided instructions to remove it.
    • If you are using Windows RT 8.1 or newer, your computer is equipped with Windows Defender. To scan for viruses, open Windows Defender. Click Settings > Advanced. Check the box next to “Scan removable drives.” Every time you run a full scan, your USB drive will be checked for viruses.[2]
    • Some anti-malware software will automatically scan your USB drive every time it is inserted into your computer’s port.[6]
    • If your Windows computer is not equipped with anti-virus software, download a reputable program.[3]
  3. Remove the autorun virus. To rid your portable drive of the virus, you need to delete the autorun.inf file and restart your computer.
    • Click Start > Run.
    • Key in “Cmd” and hit Enter.
    • In the Command Prompt Window, type in the letter associated with your drive followed by Enter.
    • Type attrib -r -h -s autorun.inf and hit Enter.
    • Type del autorun.inf and then press enter Enter.
    • Restart your computer to complete the process.[7]



Tips

  • Try scanning all of the files you would like to copy to your computer to see if they're safe and not infected. If it's a picture you love and it's infected, print it out before deleting it, then scan it back to your computer. You'll thank yourself.
  • Always scan your computer after this procedure as the virus could migrate from the external USB storage device to your main drive.

Warnings

  • Every file you copy could be infected, if you can't afford to lose an infected document or picture, print it out and scan it back to the computer from paper.

Related Articles

Sources and Citations