How to remove virus infection by Command prompt in Windows 10 – Delete Trojan using Cmd

remove virus infection by Command prompt

You can delete the virus from the computer via the command prompt. This can also remove the virus infection from the drive. This can be a little longer process but it is more effective in some of the cases where antiviruses fail to do it.

Know what damage a virus could do to your Laptop or Desktop


Virus generally comes to our PCs. Do you how a virus can be dangerous to your PC. There are multiple types of viruses which can behave in any way to harm your PC. A Virus is a program that instructs computer in unethical way. This program is created to erase someone’s file or gives hackers an unauthorised access of the infected machine.
Virus are so bad that a computer can completely be hijacked. There are so many virus popular i.e.

  1. Locky virus
  2. CryptoLocker
  3. Ransomware

How to remove Shortcut virus using cmd step by step without Anti-virus

If you don’t know much about the computer virus then in a summary you should know that these are some destructive programs that are designed by the programmers for some bad intention. If your computer is infected with a virus & some times your antivirus is not able to solve the problem for you. If the condition persists with any other antivirus too, then we format our computer. If you know about the trick we are telling you then it is much easier for you to solve the problem of virus infection. You can clean your computer by these virus infection by command prompt.
The most common reason when the antivirus is not able to remove the virus infection is that the virus converts itself into a file. This file is not detectable by the antivirus. Most common infection in this list is by Autorun.inf, newfolder.exe, ravmon.exe, svchost.exe etc.

Remove Virus Infection Via Command prompt without any software

The command which we can use to remove virus infection is attrib. before you start using these command , you need to learn a little basics of the command.

  • R – This means that the file can be used to read. No execution or updation can be done afterwards.
  • H – This means the file is to be hidden from the other users.
  • A – this attribute helps a file to be kept as archive or ready to archive .
  • S – this gives a file or a folder system attribute from being a normal user file.

ATTRIB{+attribute/-attribute}{pathname}[/S[/D]} – This is an attribute syntax. read to know about the components of the syntax.

  1. +/-  This is used to add or remove a specific attribute.
  2. D  includes any process folder.
  3. S – searching through the entire path which includes the sub-folders too.
  4. pathname – where the target folder is located.

Syntax of Command for Virus Infection – Remove virus using cmd attrib

Syntax of attribute command :- ATTRIB{+R/-R}{+A/-A}{+S/-S}{+H/-H}{+I/-I}{drive:}{path}{/S[/D][/L]}
As now we know all the basics of the command. Now learn it to use in the removal of virus infection. This can remove the virus infection from the hard disk , USB drive or even SD card.
As an example we can transfer an Autorun virus in our E drive. The extension for the Autorun virus in autorun.inf. After this follow the steps given to you.

Also Read : Learn Ping of Death Attack using Command prompt

  • Open command prompt by searching in cmd & right click on “Run as administrator”.
  • Type the drive letter in which your autorun is located & press enter.
  • Now type “Attrib” & press enter. You will see all the files inside it & the autorun also.
  • Now to remove the viruses from the drive you just need to type the command i.e. “attrib –r –a –s –h . “
  • The command will remove the read only, archive, system and hidden file attribute from all the files.

-r  to remove read only files
-a  to remove the archive file
-s to remove system file
-h to remove hidden file
. for files with all different types of file extensions
We are responsible to tell you that the command which is used in the above step will  not delete the autorun.inf but it will only remove the different attributes form the files.
To delete the virus. You need one more command that is “delete autorun.inf”. This will delete the virus file from the drive instantly.
Now If you have any questions regarding the information. We will be pleased to help you with it. Please drop a comment in the comment box so that we can help you solving your problems. Thank you.

Leave a Comment