4 Methods: Recover Virus Infected Files From USB Safely
This article explains how to recover virus infected files from USB flash drive or pen drive. You will learn effective methods to retrieve hidden or deleted files, use antivirus and data recovery tools, and safely restore your data while preventing further infection.
User Case
I have a brand new 64 GB SanDisk USB flash drive. Today, I plugged it into my work computer and noticed that all the files were missing. When I connected the drive to a spare computer at home, I saw a shortcut named Документы, but trying to open it displayed an error saying onPC.js is missing. It appears that the USB flash drive has been infected by an unknown virus. Is it possible to remove viruses from USB or recover virus infected files from the USB?
What Will Happen When USB is Attacked by Virus?
Viruses and malware targeting USB drives are quite common, as these portable storage devices are frequently connected to multiple computers and shared between users. Once a USB is infected, the virus can hide, delete, or modify files, create malicious shortcuts, and even spread to other connected devices.
Briefly:
- Permanent file loss – important files may be deleted and become unrecoverable if not addressed quickly.
- Corruption of documents – files may become unusable or damaged.
- Risk of spreading infection – the virus can infect any computer the USB is plugged into, putting other systems at risk.
How to Recover Virus Infected Files from USB?
As we have seen, when a USB drive is infected by a virus, your data is at risk and the infection can easily spread to other devices. Lost or hidden files can also disrupt work or personal tasks. Fortunately, there are effective ways to recover files from a virus-infected flash drive. The best method depends on whether you have a backup, the type of virus, and the USB’s condition. Here are some practical approaches for different scenarios.
Before Recovery: Use Antivirus Software First
Before trying to recover any files from virus-infected USB flash drive, it’s crucial to remove the virus from the USB. Scanning with reliable antivirus software prevents the infection from spreading and ensures that any files you recover are safe. This is especially important if the virus is actively creating shortcuts, hiding files, or modifying data.
Connect the infected USB to your computer without opening any files. Ensure your antivirus software (e.g., Windows Defender) is up to date. Right click the USB flash drive in Windows File Explorer, select "Scan with Microsoft Defender”, then follow the prompts to quarantine or remove any detected viruses.
Once the scan is complete and the USB is clean, you can safely proceed with data recovery using backup or recovery software.
Method 1. Recover USB Hidden Files Infected by Virus Using CMD
If a virus has hidden your files on the USB drive, you can often restore them using the Command Prompt. This method works well when the files are still intact but the virus has changed their attributes or created malicious shortcuts.
Step 1. Connect the infected USB drive to your computer.
Step 2. Press "Windows + S", type "cmd", then right-click "Command Prompt"and select "Run as administrator".
Step 3. In the Command Prompt window, type the following command and press Enter: attrib -h -r -s /s /d E:\*.*
(Replace E: with the drive letter of your USB.)
This command will remove the Hidden (h), Read-only (r), and System (s) attributes from all files and folders on the target USB, including subfolders. After running the command, open the USB drive in File Explorer. You should see the previously hidden files restored. Move these files to a safe location on your computer or another clean drive.
Method 2. Retrieve Virus Infected Files from USB Via Backup
If you had previously enabled Windows File History, you can directly restore files that were lost, hidden, or affected from a virus infected USB drive.
Step 1. Connect the infected USB drive to your computer.
Step 2. Press "Windows + S", type "Restore your files with File History", and click "Open".
Step 3. Browse through all the available backups or use the search bar to locate the deleted or hidden files from your USB drive.
Step 4. Select the files or folders you want to restore, then click "Restore" or "Restore to" to return them to their original location or a different safe location on your computer.
If you didn’t use File History or prefer an alternative, you can also recover virus-infected files from a USB using Windows Backup and Restore (Windows 7), another built-in Windows tool that allows you to create backups of your files and system for recovery.
Method 3. Restore Files from Virus-Infected USB by Winfr
If you didn’t have any backup, you can use Windows File Recovery (WinFR) instead, free and offered by Microsoft. This tool works without prior backup and is especially useful for files that were permanently deleted or hidden by malware. However,it requires using the Command Prompt and is only available for Windows 10 and Windows 11.
Step 1. Download and install Windows File Recovery from the Microsoft Store.
Step 2. Open Command Prompt as administrator (refer to Method 1).
Step 3. Enter the recovery command. For example, to recover all deleted files:
winfr H: D: \test /regular (scans the H: drive for lost files and saves them to the "Test" folder in the D: using "Regular" mode)
Replace H: with your USB drive and D: with your destination drive.
Step 4. Press Enter to start the recovery. Wait for the process to complete, then check the destination folder for recovered files.
If the regular mode fails to recover virus infected files from usb flash drive and the error message saying "No recovery files were found with this mode" pops out, switch to "extensive" mode instead: winfr H: D: \test /extensive.
Method 4. Recover Virus Infected Files from USB With MyRecover
If using Windows File Recovery feels too technical or you prefer a graphical interface, third-party professional data recovery software like MyRecover is a nice choice.It can not only recover data loss by a virus attack like Trojan, malware, worms, etc., but also restore lost data due to system crash, power failure, interrupted file transfer, partition loss, drive formatting, corruption and more.

- 500+ Devices Supported | SSD, HDD, USB Flash Drive, SD Sard, etc.
- 1000+ File Formats Supported | PNG, MP4, MP3, TXT, ZIP, MSG, etc.
- 500+ Data Loss Scenarios | Deletion, Format, System Crash, Virus Attack, etc.
Step 1. Download and install MyRecover, then launch the program on your Windows computer.
Step 2. Select the USB drive where files were deleted or hiddendue to virus attack, then click "Scan". MyRecover will perform a "Quick Scan" or a "Deep Scan" to find lost or virus-infected data.
Step 3. You can make use of the Filter or Search box to quickly locate what you need.
Step 4. Check the files you want to recover, click "Recover".
Step 5. Choose a safe location on another drive to save them, ensuring the original data is not overwritten.
The cost primarily depends on the number of files you choose to restore. Once the recovery is finished, a notification will display the total number of files successfully restored and the folder where they have been saved for your easy access.
In the End
After reading through this article, you should know that recovering virus infected files from USB drive is entirely possible with the right approach. Whether you use built-in tools like Command Prompt, File History, Windows Backup and Restore, or professional software like MyRecover, acting quickly to avoid overwriting original data is the key.
To make virus-infected files recovery easy, quick and efficient, using MyRecover is a wise choice. No prior backup is needed, and no technical commands are required, but just a few simple clicks can get it done. Moreover, it is able to recover files from system crash, formatted drive, lost partition,and more.