How to Delete a Virus Program Using the Command Prompt

Techwalla may earn compensation through affiliate links in this story.

Anti-virus software can be very expensive and doesn't always find new breeds of computer virus. You can learn to locate and remove a virus yourself without using ant-virus software. By using the command prompt you can enter the infected drive, locate the virus, render it harmless and delete it from your system for good.


Step 1

Click the "Start" menu and type "CMD" into the "Run" box and click "OK."

Video of the Day

Step 2

Select the drive that is infected with the virus. If you are not sure which drive is infected, start with the "C:" drive. Type in "C:" and press "Enter" to access this drive.


Step 3

Type the following into the command prompt box: - s - h *. * /s /d and press "Enter." This will bring up any suspicious files located on the drive. Open the suspicious file.

Step 4

Look for a file that contains a ".exe" file and a file titled "autorun.inf." If you find these two files, you have found the tainted file. Make sure to write down the name of the program where the file is located.


Step 5

Rename the "autorun.inf" so you can access the drive later without activating the virus. Type: rename autorun.inf as virusfile and close out of the "Command" prompt box.

Step 6

Double-click the "My Computer" icon and select the drive that has the infected file. Find the program that contains the infected file.


Step 7

Right-click on the program and choose "Open."

Step 8

Right-click on the file you renamed "virusfile" and choose "Delete."

Step 9

Right-click on the ".exe" file and choose "Delete." You have now removed the virus from your computer's hard drive.


Before messing around in your hard drive, always make sure to make a backup copy of your files and programs. This will protect you in case you accidentally delete an essential file from your system.