How To Remove Virus Using CMD In Windows

A Virus is a type of malware which replicates and infects your computer.The virus may cause damage to your data, overwrite or it will delete the data.Virus may spread through browsing on the internet, downloading any infected software and also through USB drives.There are various types of anti-virus softwares which helps us to protect our computer from virus.So today we are going to see a method by which we can remove virus using CMD from any drive in windows.

Some of the well known virus are ravmon.exe, new folder.exe, autorun.inf and so on.In this method i will show you how to delete autorun.inf type on virus.

These are the basic attributes and  commands which we are going to use in this method.

Basic attrib syntax:


+/-  to make or to cancel the specified attribute.

pathname – path where the file or folder is located.

/S – searches the entire specified path.

/D – to include any process folder.

Proper attrib syntax:


R – represents the read only attribute of a file or folder.

A – represents archiving.

S – changes the selected files or folders in to system file from user file.

H – represents hidden attribute.

attrib -r -a -s -h*.*

-r = to remove the read only files.

-a = to remove the archive files.

-s = to remove the system files.

-h = to remove the hidden files.

*.* = to select all files with different types of extensions.

These are the explanations of the commands which we are going to use in this method to remove virus using CMD.

How to remove virus using CMD:

1.Open command prompt with administrator access.

2.Enter the Drive which consists the virus.Suppose, for example if the virus is in F drive just type F:( change the drive as per your need) and hit enter.

3.Now type attrib and hit enter.This command will display you all the files present in the drive so that the autorun.inf virus also gets listed.

4.Next type the command attrib -r -a -s -h*.* , this command will remove the read only, archive, system and hidden file attribute from all the other files.

5.The above command will not delete the virus from the drive it will only remove the attributes from files, so in order to delete the virus we have to enter the command del autorun.inf and hit enter.The file will get deleted.To delete virus with other extensions (.exe) just type del *.exe respectively.

If you want to delete the files from USB, enter the USB drive letter and follow the same process.This is how we can remove virus from any drive using CMD.

Leave a Reply