How to Remove Virus Using CMD & Recover Files Deleted by It?

How to remove virus using CMD? Found virus deleting files from computer? Check out this article to get virus deleted and files back easily and safely.

By @Lora Last Updated September 13, 2024

"How do I remove a virus from Windows 10 via CMD?"

Most computer users won't be unfamiliar with computer viruses. Many users may have heard of famous viruses like Mydoom, Wannacry, Zeus, etc.

Simply put, a computer virus is a program that can reproduce itself and run without the user's knowledge or approval, usually causing massive disasters like enabling vast PCs worldwide.

The main types of viruses are Boot Sector viruses, Resident viruses, File infector viruses, Macro viruses, etc. Also, there are Trojan Horses, Worm viruses, ransomware viruses, and so on.

The common symptoms of infection by computer viruses are data loss, personal info loss, system failure, data corruption, etc.

And now, some users are wondering if it is possible to get rid of viruses via CMD and how to remove viruses using CMD safely.

   
   
   
       

Deleting virus using command prompt

       

Hello, I would like to know the procedure for selecting a virus in my computer using the command prompt.

       

- Question from CCM

   

In addition, a considerable number of users are asking whether a virus deletes users' files because sufficient evidence shows that viruses delete files from the computer. Check out the next section.

Can viruses delete files?

Definitely yes. Except for some "mild" damage like occupying system resources, viruses are more likely to have explicit purposes: delete files, encrypt disks, format disks, etc.

If you find your files have been encrypted abruptly, it is likely to be the virus.

For data loss brought by viruses, specifically speaking, some viruses can overtake the operation authority of your computer drives and maliciously delete, hide, etc., your files.

But don't worry; you can get help in this post to remove viruses and recover files deleted by viruses.

If you are lucky enough, you could show hidden files in File Explorer that were hidden by viruses.

But in the next section, let's discuss why a group of users questioned if they could delete viruses using CMD.

Why do you need to use CMD to delete viruses?

Why is Command Prompt necessary when you need to get rid of the virus? In addition to the usual symptoms that a virus may bring, one of the most prominent is being unable to operate the computer.

For example, users may meet BSOD, reboot loop, and find they cannot move their mouse, etc.

Thus, users cannot simply remove the virus generally in the computer's GUI (graphical user interface) as usual. But thanks to the Command Prompt, users could merely operate their computers using their keyboards.

On the contrary, if you can luckily operate the computer, then you can remove ransomware viruses easily.

In the following part, we will walk you through the detailed steps of removing the virus via Command Prompt.

How to remove viruses using CMD?

Command Prompt, aka cmd.exe, allows users to execute operations using commands. Different commands can help you do various things. E.g., you could use the Recover command in CMD to restore readable info from a corrupted hard drive.

To utilize it to delete viruses, you need to figure out the location of the virus.

Firstly, when did you find abnormal symptoms like random prompts, instant rebooting, etc.?

Secondly, what caused these? There must be a symbolic event:

  • You may have downloaded some suspicious programs.
  • You may have visited suspicious websites.
  • You may have clicked dubious attachments in emails from strangers.

Deleting the virus would be easier if you could recall the suspicious file or its location.

Thirdly, now, follow the detailed instructions to learn how to remove viruses using CMD.

Notes:✎...
Please be careful to operate the Command Prompt because if wrong commands are executed, it may cause further damage to your machine or the data.

Step 1. Press Win+R to launch the Run window > input runas /user:administrator cmd > input the administrator's password.

Step 2. Input d: > press Enter > input dir d: > replace the d here with the correct drive letter of the partition where the viruses stayed.

Step 3. Input dir d: attrib –s –h /s /d *.* > press Enter > locate the displayed suspicious files, especially those named with autorun and end with the extension inf > input del: autorun. Inf.

How to recover files deleted by viruses?

If you found a virus deleting files from your computer, and now, with the virus successfully removed, it is time to recover files deleted by the virus.

To recover deleted files from the hard drive, you could also use Command Prompt. Like some users who are familiar with CMD would like to recover Flash Drive files using CMD.

But it is also very complex and pretty dangerous. Instead of recovering files using CMD, ordinary users might as well choose a professional Windows data recovery tool to help them.

MyRecover could be your firm helper. It is specially designed for Windows users, applying to multiple data loss situations like viruses, deletion, formatting, recycle bin emptying, system crash, etc.

It possesses several valuable features to help you learn how to recover deleted files from hard drives.

Recover files deleted by viruses easily
  • Support data recovery from internal & external HDD/SSD/SD card/USB, etc.
  • Recover over 200+ types of Windows data, including photos, videos, office files, zip files, etc.
  • Select data to recover while scanning, saving your precious time.
  • Deleted files can be recovered with original filenames, formats, paths, and quality.
  • Compatible with Windows 11/10/8/7/Server.

 

Download SoftwareWin 11/10/8/7/Server
Secure Download

Now, please follow the steps to perform data recovery in a breeze.

Notes:✎...
We suggest you select a different place to store the recovered files to avoid data overwriting.
The software scans your hard drive using Quick Scan and Deep Scan to search for deleted and missing data.

Step 1. Install and run the software > hover the mouse over the source drive where the files were deleted by virus > click Scan.

Step 2. If you can recall the extensions or filenames, you could input them in the search box to search for them. Also, you could target the wanted files quickly with Size, Type, Date modified, etc.

Step 3. Go to Deleted files > navigate to the original location > select deleted files > click Recover x files. If failed, check the Other missing files and select files to restore.

Also, this helpful app could help you undo quick format to get files back.

Related suggestions

In this post, users who have encountered a virus attack could learn how to remove the virus using CMD. Furthermore, utilizing an efficient Windows data rescue app will be preferable to deal with data loss brought by viruses.

What's more, to improve the security level of your machine, there are additional suggestions for you.

  • Do not visit fishy websites. Do not open email attachments you cannot identify and send from strangers.
  • When you need to download apps, go to dependable sites.
  • Watch out for bundled software; make sure to uncheck and do not download them.
  • Use antivirus software to protect your machine.
  • Upgrade the antivirus programs regularly.
  • Back up your important files regularly. Use professional data backup software for Windows to achieve so.