Sometimes viruses can slip through your defense systems and compromise your operating system. If you’re in a pinch, you can attempt to remove common computer viruses without antivirus software with the help of command prompt.
- Things to Consider Before Using Command Prompt to Remove Viruses and Malware from Your PC
- How Do Computers Get Infected with Viruses?
- How to Tell If Your Computer Is Infected with Viruses
- How to Scan Your PC for Malware Using Command Prompt
- How to Identify Viruses
- Search and Remove Viruses Using the Attribute Command
- Frequently Asked Questions
Things to Consider Before Using Command Prompt to Remove Viruses and Malware from Your PC
Only use the command prompt to remove viruses if you have some technical understanding of how computers work. Running specific commands with administrator privileges may be risky, and you can lose your data or system files if you misuse them.
Apart from that, there’s a limit to what the command prompt can do to remove malware. You can use it to delete some common viruses, but you can’t do it with others. For instance, you can’t remove ransomware with the command prompt. For that, you’ll need software that can decrypt your files.
Ensure you have administrator access to your PC, as without it, some viruses won’t be removed successfully.
How Do Computers Get Infected with Viruses?
One way to reduce the risk of a malware infection is to learn how computers catch viruses and avoid that. Your computer can catch a virus in several ways:
- Downloading data from unsafe sites can infect your computer with malware. Most websites that support movie, audio, game, and software piracy are rife with viruses.
- Spam emails also carry malware, and opening any attachments from them may infect your computer.
- Ads and pop-up notifications can also download malware into your computer when you click on them.
- Attaching an infected peripheral device (like USB drives or external hard drives) can also infect your system with viruses.
- Connecting to unsafe networks can expose your computer to viruses already present within the network.
How to Tell If Your Computer Is Infected with Viruses
If you fall sick, you’ll experience symptoms that help doctors determine your illness. Computers are similar to us in that aspect. Once infected, your computer will behave in an unusual way to alert you of a possible compromise in its operating system.
Here are some examples:
- Computer performance slows down, and your device takes too long to start up and run programs.
- Some malware will cause your PC to overheat or your fans to run with a jet-like noise.
- You may lose access to some or all of your files, or the malware may delete them altogether.
- Although you didn’t download them, unusual applications may appear on your Desktop and Start menu.
- Your browser may slow down.
- You’ll begin to receive repeated warning notifications from your antivirus software
- Unexpected system shutdowns and restarts.
- Overworked CPU, RAM, and hard drive.
- Some malware may hijack administrator privileges and deny you access to some or all your PC functionality.
How to Scan Your PC for Malware Using Command Prompt
Before removing any virus from your computer using the command prompt, first, scan your system. Most viruses will hide within your system files or drives, mostly changing their properties to stay invisible or undetected.
To scan for malware using command prompt:
- Open the command prompt with administrator rights. You can do so using your search bar or the Run function.
- Once done, you’ll receive a prompt to confirm you want to use administrator rights on your PC. Click “Yes” to continue.
- Once done, a CMD window opens.
- To begin your scan, type
sfc /scannowand press Enter.
- Depending on your PC specifications, this process may take some time. Wait until the scan is complete.
Windows will also attempt to repair any corrupt files as this scan happens. In some cases, this may resolve your issues. If not, you may have to search and delete the virus files from your drives.
How to Identify Viruses
Identifying computer viruses isn’t always a straightforward process, but once identified, you’ll know how to remove them. Here are several ways to identify viruses on your PC.
Many antivirus software solutions already have massive databases of different types of malware. Using them to scan files can help you identify a virus by name.
Windows Defender, for example, uses its internal behavioral analysis tools to determine if a file or program is some form of malware. Commercial antiviruses also have this capability.
How did malware infect your PC? Did you download it from a file attachment in your e-mail? Jot down the details of that email and scan the file for viruses. Was it from a USB drive? Scan all the files inside it for suspicious files. Once you identify the problematic file, you can delete it.
By PC Behavior
Although less clear, you can use the behavior of your computer to determine what malware has infected it.
Ransomware, for example, encrypts your files and denies you access to partitions in your hard drive. Adware causes annoying pop-ups on your browser and computer when surfing the Web.
While ransomware may require decryption software, adware will be easier to deal with.
Search and Remove Viruses Using the Attribute Command
To remove viruses from a specific drive or partition, you can use the
attrib command. This command can set, display, and remove several properties from files and folders.
Here’s a quick rundown of how to use the attrib command. To run the command, you must call it using
Rrepresents the Read-Only attribute
Srepresents the System attribute
Arepresents the Archive attribute
Hrepresents the Hidden attribute
+applies the chosen attribute to a file or folder
-removes the selected attribute from a file or folder
/Ssearches through the entire document path, including subfolders within folders
/Dincludes any process folder
Pathnameis the location where the target file or folder is.
This command can get rid of several types of viruses, including “autorun.inf” and the Glupteba trojan.
How to Remove a Virus With The ‘Attrib’ Command
- To begin, run the command prompt with administrator privileges
- Once the CMD opens, select the infected drive using its letter. (in my case, E:) This keeps all the functions you’ll run within this partition.
- Use the command
dir [drive-letter]: attrib -s -h /s /d * . *to get into your chosen file/folder.
- Once you’ve identified the unwanted file, you can now delete it with the command:
Doing this deletes the virus permanently from your system
What Viruses Can CMD Remove?
It depends on the virus itself. CMD can delete some viruses but won’t delete others.
You can use cmd to delete common low-level viruses like “autorun.inf”. For more complex viruses, you’ll need dedicated antivirus software to remove them from your system completely.
Viruses have different behaviors, and some replicate themselves into the registry and may alter or delete system files. To delete such a virus would require you to repair the system and recover files as well.
Where possible, use antivirus software to remove complex malware. If your computer system gets a ransomware infection, cmd won’t do much to help you – at least not yet.
Frequently Asked Questions
1. Can you really remove a virus just by deleting it?
If you follow these instructions carefully, you can remove a virus by deleting it. If you already have antivirus software, it shouldn’t be a problem. Many antivirus programs delete virus files too, and that’s usually permanent.
2. Should I use the command prompt to remove viruses instead of an antivirus software?
You could use the command prompt method to remove viruses if you don’t have antivirus installed, but it will not protect your computer from infection without the advanced features that most good antivirus software provide: e.g. quarantine, scanning, etc. You should not depend on this method to keep your computer safe from infection; rather, use it in a pinch to remove a virus if you have to.
3. Can a virus survive a factory reset?
Mostly, no. Resetting your computer restores it to its condition before you bought it. It’s an effective way to clean your hard drive of viruses and repair damage.
Our latest tutorials delivered straight to your inbox