How To Remove Virus Using CMD? Complete Guide

Are you looking to know how to remove virus using CMD? Then we are here to give a proper guide for utilizing the CMD (Command Prompt) to remove computer malware. To learn more about it, read the entire post.

In order to remove a virus using CMD:

  1. First, Enter cmd in the search box, then select “Command Prompt” from the context menu and click “Run as an administrator”
  2. Press “Enter” > Now Hit “Enter” after typing “attrib d” > Click “Enter” after typing dir. You will now see every file under the designated disk.
  3. Use the del autorun.inf command > Press Enter to remove the files.

To know about these steps in detail, read the article.

Viruses can enter computers through USB devices, web browsing, and malicious software, making them run slowly and potentially stealing data. To quickly and efficiently remove them, CMD is recommended. Read the article on how to remove virus using CMD to know more.

What Is a Virus?

A virus is dangerous software that copies itself to another application on your device and multiplies by altering how your computing device functions. When an infection is deliberately or accidentally propagated without notifying the user or administrator, it is called a viral assault.


A CMD virus may infect your computer in several ways, including clicking on a link or a file, viewing a website known to have viruses, accessing an email, etc. It may also spread through portable storage media like SD cards, pen drives, and USB flash drives.

Visit: Virus

How Could a Virus Harm Your Computer?

Viruses come in a wide variety and exhibit a variety of behaviors.

virus harm your computer

A virus alters how your device works, so it may delete or destroy crucial files, allow hackers access to your data, and track people’s behaviors, among other things.

See Also: How to Remove Virus from Mac OS [10 Proven Ways]

How to Stop a Virus Attack

Here are some strategies to protect yourself from a viral attack:

  • Regularly doing an antivirus scan.
  • Continue to update your antivirus program.

virus attack

  • Disable the Auto-run option to prevent malware from spreading to any media connected to your computing device.
  • Always update your system’s operating system and installed programs.
  • Use extreme caution when clicking any email-based link.
  • Construct a firewall.
  • The systematic online or email file download.

How Can You Tell If A Virus Is Attacking Your Computer?

These are the warning signs that would alert you to any viral assault.

virus is attacking your computer

  • The computer system frequently crashes, shuts down, and has issues.
  • Computer malfunctions, such as ones that don’t react to clicks.
  • Invalid email.invalid email
  • The device’s storage memory decreases.
  • The PC is missing files or data.
  • The hard disk of a computer is always rotating and making noise.

Those mentioned above are some crucial ideas to remember to shield your system against a malware attack. People who could encounter this issue might think about the following instructions on removing the pendrive virus using CMD.

How to Remove a Virus Step by Step Using CMD

Let us see how to remove viruses step by step.

Step 1: Type “Command Prompt” into the search box to open it, then execute it as an administrator.

search command prompt

Step 2: After CMD opens, enter D: and press return. (Change D to the desired drive letter.)


Step 3: At this point, input the command attrib and press Enter to run it. The autorun. Inf malware files will be shown for you to see.

Step 4: To run the command, type attrib -r -a -s -h *.* and press Enter. This command will remove the read-only, system, archive, and hidden file characteristics from all the files. An asterisk indicates files with various extensions (*-). This is the shortcut virus remover using the command line.

Step 5: To delete the files, use the del autorun.inf command and hit Enter. Suppose your system is infected with another virus, such as the.exe or. Ink extension, replace autorun. Inf with that filename. These instructions on how to remove virus using CMD can be used to assist you in cleaning your device of infections.

Other 3 Virus Removal Methods

In addition to utilizing CMD to remove shortcut viruses, you may use antivirus software like Windows Defender or format the storage device to eliminate viruses from your computer or storage device.

Method 1. Run Antivirus

Virtually all computers are equipped with antivirus software.

run antivirus

Running the antivirus program may be helpful if you discover that your machine is infected. This is the best solution to “how to delete a virus from a laptop.”

Method 2: Utilize Windows Defender Antivirus

The built-in antivirus security in Windows 10 and 11 is Windows Defender Antivirus. It protects against malware, spyware, and viruses for your computer and any attached devices. Use the integrated tool if you don’t have antivirus software from a third party.

1: Open “Settings” and then select “Update & Security” and then “Windows Security.”

windows security

2: Click “Virus & threat protection.”

virus and threats protection

3: Click “Scan now” under “Threat history” to check your machine for infections.

scan now

Method 3: Format the infected device

The format procedure involves deleting all of the files currently present on the specified partition or storage. It will undoubtedly also get rid of the infection.

format the infected device

As formatting a partition or disk can result in data loss, be sure the device doesn’t contain any crucial files. So this was all in the how to remove virus using CMD article.

See Also: Remove Virus Completely | Easy Guide for 2024


What is a virus command?

The virus can be used to check a file system for the existence of computer viruses. If the Directory variable is given, the virus can command scan the directory (and each subdirectory).

How are viruses eliminated?

Utilizing an antivirus tool to clean your system securely is the simplest approach to getting rid of infections. However, there may be extremely particular circumstances in which you must launch this application if a virus is already on your machine.

Why is virus removal important?

The ability of viruses to compromise computer security is the primary justification for seeking virus elimination. Even installed antivirus software might be disabled by some more destructive ones. As a result, a computer becomes even more susceptible to malware and viruses.

How can I use CMD to scan and repair?

In the Start menu's search box, enter CMD (Command Prompt) and click Run as administrator. Press Enter after typing chkdsk. While CHKDSK will check for drive problems and inform you if any need to be repaired, it won't attempt to do so without a command.

Can CMD get rid of viruses?

By displaying any hidden infections on a partition or drive, CMD aids in the removal of viruses from your computer. You may then remove the questionable files. Since viruses usually try to hide, you must first make them visible before deleting the viral files.

How does CMD find IP addresses?

To begin, go to your Start Menu, select the search box, type CMD, and hit Enter. You should type ipconfig /all and push Enter to launch a window in black and white. There is a gap between the command ipconfig and the switch of /all. An IPv4 address will be assigned to you.


A virus assault may cause a lot of trouble by ruining your computer’s functionality. You may even encounter CryptoLocker Ransomware, which encrypts all of your data and demands payment in Bitcoin to decrypt; if you don’t, the CryptoLocker will trash all of your papers in a predetermined amount of time.

There are several techniques to ensure that your computer is operating normally and guarding against virus or ransomware infections. Several ways are available to remove a virus from your computer, but using them could cause data loss. We hope you liked the article on how to remove virus using CMD.

See Also: Remove Fuq.Com Virus Completely | Easy Guide For 2024