Remove Viruses Using Command Prompt Windows 10
Pendrive is a handy mobile gadget for transferring and carrying data. Consequently, it also gets attached to many computers that boost up the chances of computer virus infection. Because computer viruses are capable to replicate and spread by itself. Another property of computer viruses is that it can change the attribute of files, therefore, you can’t access viruses infected file properly.
Now if somehow your Pendrive gets infected by computer viruses then you cant be able to access all the files from your Pendrive. Therefore you will be in real trouble in such a situation.
Using antivirus for removing viruses from your Pendrive is the recommended method but there is also another way you can deploy for removing viruses from Pendrive without using antivirus. In this article, I will share the second method of removing viruses from the Pendrive i.e: How To Remove Computer Viruses From Pendrive Using Widows 10 Command Prompt.

How To Remove Computer Viruses From Pendrive Using Widows 10 Command Prompt:

This method includes two steps:

  1. Virus detection
  2. Delete Them

In both steps, we use Windows Command Prompt.

1)Detect Viruses Using Command Prompt:

Generally, viruses present in Pendrive in the form of an executable file format like Ravmon.exe, New Folder.exe, svchost.exe, Autorun.inf,Heap41a, etc.But those remain invisible because of the hidden attribute or even if visible still you can’t simply delete it due to their Read-only attribute. Therefore, we’ve to change the Hidden and Read-only attributes first to detect those viruses. To do this
  • Connect the Pendrive with PC.
  • Run Command Prompt as an administrator
Run Command Prompt as an administrator
  • Type Pendrive location for selecting the particular drive. In my case, the location of the Pendrive is ‘F’ so I am going to select ‘F’ drive by typing F: and then press Enter
  • Now type attrib. It will list out all unwanted hidden and read-only files or folders from the Pendrive. You can say these are the list of viruses that exist in the Pendrive

2)Remove Viruses Using Command Prompt:

After performing the above step you’ll be able to see the list of viruses those present in Pendrive. However, due to their Hidden and Read-only attributes, you can’t be able to find and delete those viruses just by opening the Pendrive. Therefore you need to remove Hidden and Read-only attributes first to delete them.For this type the command given below

attrib -h -r -s -a *.* and press Enter.


  • h represents the hidden attribute
  • r represents the read-only attribute
  • s represents system file attribute
  • a represents archive attribute
  • *.* represent all the files with all different types of file extensions. And
  • ‘-‘ represent removing an attribute
Now, you will be able to find those viruses by opening the Pendrive or USB Drive. Also, you can delete those viruses either by using command or normally as you delete other files from your computer.

2. To delete this using command prompt, type del file location filename and press Enter. For example, del C:UsersG~NOXDesktop svchost.exe and press Enter. Once you have pressed enter, that file should get deleted from the current drive.


Final Words:

Antivirus is more powerfull and rife with lots of advanced features. So using antivirus for removing viruses from a storage device is the favored way. But, if you wish to try an unusual way then you can use the windows command prompt for this. Finally, it’s up to you.

Leave a Reply

Your email address will not be published. Required fields are marked *