How to remove virus using command prompt [ No Antivirus Needed]

Viruses, malware, trojans, worms! These evil things can penetrate your computer through numerous ways like internet browsing, from USB devices, phishing links in your email and also by installing infected software.

Most of these viruses make your computer slow and eat up valuable memory as well as storage space. Some more powerful viruses are meant to contaminate our operating system too and steal personal information and banking data.

Also Read- Best Free Antivirus Software For Windows 10

The conventional method to identify and remove such unwanted programs from your computer is to install anti-virus software and scan your computer for any viruses/trojans/worms that exist and quarantine them.

However, there are some computer users out there who use unconventional methods to find such a virus and remove them without using any antivirus software.

Today we are discussing such an unconventional method by using Command Prompt or DOS Prompts to identify and remove viruses. 

Also Read- A-Z Windows CMD Commands List

The method is simple and straight which even a layman computer user can proceed with, just follow the steps given below :

Remove Computer Viruses Using CMD, without any antivirus

The Command Prompt or CMD/DIS Prompt is a command-line utility program on Windows 10.

Though the command prompt is rarely used by layman PC/laptop users, it is a powerful utility in the hands of pro hackers.

CMD has access to reconstruct all Windows system files by using various attributes like removing the hidden attributes which a virus normally uses.

One of the leading causes of virus infections in computers and the CMD method work on USB to remove its viruses and secure your computer.

Step 1. Click on Start and type cmd. Now right-click on the cmd icon and select run as administrator.

Running the command as administrator is important as you need to access the system files which are not usually visible in guest accounts.

Now command prompt window will open, now select your drive from which you want to remove a virus.

command prompt

Step 2. Let us suppose your USB has a virus and your USB drive is F. Type “F:” without quotation on Command line.

usb drive f

Step 3. Now the C: will change to F: Now you need to type “dir F:” in CMD and hit enter. It will show you the directory of the F drive.

directory f drive

Step 4.  So now type the following command to show all the hidden and system files on your USB drive. Type “dir F: attrib -s -h /s /d *.*”  without quotations and press enter. Typing this command will explore your selected drive and will load all the files including hidden and system files on your drive.

explore drive

Step 5. In this window, you will notice unusual file.exe  and extension if your computer has been infected with a virus like the dreaded autorun.inf virus.

Rename it using this command line rename filename.extension new filename. Usage > C://rename autorun.inf (new filename)

rename virus

That’s it!  Now you can identify all the viruses in your PC and USB and delete them without any help of anti-virus software. You can delete the autorun.inf by typing in the command “del autorun.inf” or del :”yourfilename”

Subscribe to our newsletter

To be updated with all the latest news


  1. my Windows xp computer screen doesn’t show anything and i have even tried to change the screen but it even doesn’t work could the problem be the operating system or what please help me am very worried

  2. As I am seeing that you are posting lot of hacking stuff on this site so can you please help me out. I jus want to know how to port forward on mobile tethering as I need for this to some metasploit over WAN in kali Linux

  3. on the fifth step i am being confused. i had typed rename autorun.inf(file name)
    cmd shows “the system cannot find the file specified”.
    what should i do now?

  4. The above won’t work – you first need to check your tasks/processes to verify the virus/malware is not running, and kill the running EXE prior to deleting it, otherwise it will simply re-infect the device again a second or so later, and all the work you’ve just done was for nothing…

    Easiest would be to follow the above steps, but before you delete anything, hit [Ctrl] + [Shift] + [Esc] to open “Task Manager”, sort it alphabetically, locate and kill the desired EXE.
    Wait about 10sec to see if it starts up again – if this is the case, just use a free online virus scanner (or downloadable demo/trial solution) from a reputable provider to clean your entire system…that’s the easiest 🙂

    Anyway, after killing the EXE, and it didn’t start up by itself again, you can safely delete the virus/malware application files. But, having done all of this – you still need to scan your machine with a proper cleaner to remove the ones you cannot locate via CMD Prompt.


Please enter your comment!
Please enter your name here

Subscribe to our newsletter

To be updated with all the latest news

Read More

Suggested Post