How To Remove Computer Virus Using CMD

Virus is a type of malicious software program (“malware”), when executed, replicates by reproducing itself and infects other computer programs by modifying them. Virus can be transferred from one system to another. Some of the viruses are remain undetected even by your Antivirus and  to deal with it, you have to use another method.

Here, we have discussed how you can get rid of virus on your own. You can detect and remove computer virus using CMD(Command Prompt) and safe the important data on your system as well.

Command Prompt is a command line interpreter application available in most Windows OS. Command Prompt is used to execute entered commands.

Before using Command Prompt, let us know some basic commands about the same.

See Also: How to Remove Virus from Pen Drives

Attrib – The command allows a user to change the attributes of a file or files. With attrib, you can change, add or remove any of the attributes. These are the different attributes used now and then

  • ‘+ / –’: To enact or to cancel the specified attribute.
  • ‘/S’: Searching throughout the entire path including subfolders.
  • ‘/D’: Include any process folder.
  • ‘pathname’: Path where the target file or folder is located.

Steps To Remove Computer Virus Using CMD

Now follow these steps to know if your system is infected:

Step 1

Open Command Prompt with Administrator rights. Click on Start Button and type Command Prompt or CMD, make a right click on it and select the option ‘ Run As Administrator’.

run as admin

Step -2

Now you need to enter the drive, which you suspect is infected. Let us say, it is D drive on which you suspect. Use this command “D:”

cmd open

Step 3

Now you can see C will change to D. Type dir D: and hit enter. Following this command, will show you the directory of D drive.

remove virus cmd open

See Also: How To Protect Your Computer From Malware

Step 4

 Type “dir D: attrib -s -h /s /d *.*” and hit enter. This command to search through all the hidden and system files on the drive.

This command will search through the selected drive and load all the files including hidden and system files on that drive.

pen drive virus remove

 Step 5

In this window, you can check for unusual files with .exe extension if your system is infected. Let’s say you have a autorun.inf virus. Before deleting the file, you need to rename the file by using this command – rename filename.extension new filename.

 rename autorun

In this way, you can identify virus on your system or USB and delete them without using Antivirus program. Now that, you have renamed the file, you can delete the autorun.inf by typing in the command “del autorun.inf” or del :”yourfilename”

These are the simple steps to remove virus from your Flash Drive or your computer. You may also notice a speed enhancement on your system.  Try them and let us know if it worked for you.


  • comment_avtar
    bagada sagar
    thnx for the info. shrishti

    6 years ago
  • comment_avtar
    this is very usefull for me

    6 years ago

Leave a Reply

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

Subscribe Now & Never Miss The Latest Tech Updates!

Enter your e-mail address and click the Subscribe button to receive great content and coupon codes for amazing discounts.

Don't Miss Out. Complete the subscription Now.