Open In App

How to Remove Virus Using CMD?

Last Updated : 08 Mar, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

Removing a computer virus is crucial to protect your device and data. While antivirus software is the best defense, the Windows command prompt provides powerful tools to eliminate infections the antivirus may miss. Learning a few simple CMD commands could save you from a devastating virus attack.

In this short guide for beginners, you’ll learn straightforward steps to leverage CMD to scan for and erase malicious software. With some basic commands, you can keep your computer safe.

Method 1: Remove the Virus Using Del Command

Step 1: Open the Command Prompt

In the search bar, type “CMD” then right-click on “Command Prompt” and choose “Run as administrator”. Running Command Prompt as an administrator gives it extended permissions needed to access all files and folders.

1

Step 2: Select the Infected Drive

Type the drive letter of the infected drive followed by a colon (for example “E:”) and press “Enter”. This will switch you to the drive that contains the virus or malware. Replace ‘X’ with the appropriate infected drive letter.

2

Step 3: Key Attributes

Type “attrib -s -h -r -a /s /d” and press “Enter”. This will remove key attributes from files that might prevent deletion. The attributes that are removed are system, hidden, read-only, archive, files in subfolders, and empty folders. Removing attributes allows infected files and folders to be deleted.

Command:

attrib -h -s -r /s /d *.*

Output 1:

3

Output 2:

4

Step 4: Delete the Program

Now type “del autorun.inf” and press Enter. This deletes the autorun.inf file which is commonly used by viruses and malware to execute automatically. Getting rid of this can disable some infections. Find the Suspicious file or Program that doesn’t belong to your computer to delete the file Enter the Following Command.

Command:

del ( Enter_the_Program_name_here )

Output:

5

Method 2: Remove the Virus Using Taskkill Command

Step 1: Open the Command Prompt

Open Command Prompt as an administrator like before by searching for CMD, right-clicking Command Prompt, and select “Run as administrator”.

Step 2: List the Files using Tasklist Command

Type “tasklist” and hit enter. This displays a list of currently running processes and programs on your computer.

Command:

tasklist

Output:

6

Step 3: Check for the Suspicious Programs

Carefully look through the list and identify any suspicious processes that could be caused by a virus infection. These may have random or unusual names. In my case, I don’t have any viruses so for a demonstration I’m gonna Choose some of my unnecessary Programs.

7

Step 4: Delete the Program

In my case, I don’t have any viruses so for a demonstration I’m gonna Choose some of my unnecessary Programs and delete them by using the taskkill Command.

Know More about Taskkill Command here

Command:

taskkill /F /IM ( Enter_Your_Program_Name_Here )

8

After, entering the command you will see the message like SUCCESS: The process has been terminated which means that our virus is been Successfully deleted.

Conclusion

Learn simple CMD commands to keep your computer safe from viruses. Use Command Prompt as an admin to delete harmful files, check processes, and close unwanted ones. Useful commands include deleting the autorun file, showing running processes with tasklist, and force closing shady processes with task kill. Run antivirus scans for extra protection. Even without being an expert, these basic steps help safeguard your computer effectively.

Also Read

Frequently Asked Questions on how to remove virus using CMD

How does using CMD help remove a virus?

CMD allows you to access infected system files and terminate shady processes that might be caused by a virus. This stops the infection.

What type of virus files should I look for?

Be on the lookout for files with strange, random names that keep reappearing after deletion. Also watch for file extensions like .exe, .vbs, or .bat as these allow code execution. Unfamiliar processes running in task manager could also indicate an infection.

If CMD virus removal doesn’t work, what should my next steps be?

If basic CMD commands are unable to eliminate virus activity, immediately disconnect from any networks and stop using the infected device to prevent spreading. Then restore to an earlier uninfected system restore point or completely reinstall your operating system for a clean slate.



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads