Viruses are usually spread across multiple computers using USB Flash drives, external media, connected networks and the Internet. If a USB drive is infected with a virus, it will get activated when we open the USB drive on our computers.
This is because of the auto-run functionality in Windows. Windows looks for autorun.inf file in the USB drive. The autorun.inf file contains information about which program to run when the USB flash drive is opened.
Table of contents
- Remove shortcut virus from USB using the command prompt
- Disable Autorun functionality using Group Policy Editor
- Disable Autorun functionality from Windows Settings
- How to remove virus from pendrive automatically using antivirus tools
- Does formatting the USB drive remove viruses?
- How to recover data infected with shortcut virus in the flash drive?
Viruses tend to push their information in the autorun.inf file and then execute automatically from there. The safest way to use USB flash drives without infecting your own system is to disable the Auto Run functionality of Windows.
If your system is not infected by the infamous shortcut virus, you can disable the autorun functionality to keep your system safe. But first, let’s see how you can remove the virus from the infected USB Flash Drive.
Remove shortcut virus from USB using the command prompt
If your USB drive is already infected with a virus, you can safely delete the autorun.inf file and then scan the USB drive with an antivirus to make sure that the USB drive is clean from all malware.
Autorun.inf can be deleted in two ways. First, by using Windows Explorer:
- Press the Windows Key + E to open Windows Explorer. From the left hand tree, open the USB drive. This should not trigger the auto-run functionality of the USB.
- Now from the left hand content pane, delete the autorun.inf file. Make sure that you are showing hidden files from Folder Options as autorun.inf is usually a hidden file.
Secondly, you can also delete the infected autorun file from the command line.
- Go to Run –> cmd. This should open the command prompt.
- Type G: where G is the USB drive letter.
- Now run the following command. This will remove the attributes hidden, archive, system from all the files.
attrib -h -r -s -a *.*
- Enter the following command. This will delete the autorun.inf file.
Disable Autorun functionality using Group Policy Editor
To save your system from USB-related viruses, it’s safe to permanently disable auto-run functionality in Windows 10.
To disable Auto Run functionality in Windows, do the following:
- Go to Run –> gpedit.msc. This will open the Group Policy Editor.
- Navigate to Computer Configuration –> Administrative Templates –> Windows Components –> AutoPlay Policies
- In the right hand pane, enable the “Turn off Autoplay” setting.
This will prevent Windows from automatically using autorun.inf file in the USB drive.
If you want to make sure that in addition to the autorun file, the virus is also removed from the USB drive, you will need to open the autorun.inf file in notepad and see which files and executables are triggered during autorun. Delete these executables and you will be safe from the wrath of USB viruses.
Disable Autorun functionality from Windows Settings
Windows 10 Settings allows users to turn on or off Autoplay functionality of the attached media and devices.
- Open Windows Settings (Windows key + i)
- Go to Devices –> AutoPlay
- In the right hand pane, you will see the settings for each removable device.
- Configure each option with the “Take no action” option from the drop down list.
This will make your Windows 10 system safer when you insert a USB drive. The virus will not be able to run by itself. Be sure to use the Explore option instead of double-clicking on the USB drive. Double-clicking will trigger Windows to run the autorun.inf file again.
How to remove virus from pendrive automatically using antivirus tools
Most security organizations offer free virus removal tools. You just have to download the tool and run it on your computer to scan for viruses. The tool will detect and remove viruses automatically. You can use a virus remover tool from any company including Avast, AVG, Norton, Bitdefender, F-Secure etc. You can download these virus removal tools from here.
If the virus has taken over the system and is not letting you scan for viruses, you should try bootable virus scanners.
There are special virus removal apps designed to remove only specific viruses including the pendrive virus. Some of the include the following:
Does formatting the USB drive remove viruses?
Yes. When you format a USB drive, all data in the storage including the virus will be deleted. Both quick format and detailed format will remove the virus from the USB drive. But you should take extra care when formatting the USB drive. Make sure you are formatting the right drive. Otherwise, you may lose important data which may not be recoverable easily.
If your system has been infected by the pendrive virus, formatting the drive will not be very useful as the virus will replicate itself in the drive again as soon as the formatting process is complete. In this case, you should also clean your computer from viruses using the tools discussed above.
How to recover data infected with shortcut virus in the flash drive?
If your flash drive has been infected with the shortcut virus, it will create shortcuts of all the files and folders inside the pendrive. When you open any file, the virus will execute itself before opening the actual folder or file. The virus hides the actual data in the pendrive. You can see the data by selecting the “Show hidden files” option in the File Explorer options.
I hope this will be useful for you. Do let me know whether it was useful for you or not.