How does a computer get infected with a virus or spyware?

Updated: 07/13/2023 by Computer Hope
Laptop displaying a computer virus.

There are several ways spyware, viruses, worms and malware are transmitted. Below are ways your computer can become infected and spread viruses. We've made this list in the order we believe to be most to least common.

Accepting without reading

One of the most common ways a computer becomes infected is when a user accepts what they see on the screen without reading or understanding the prompt. For instance:

  1. While browsing the Internet, an Internet advertisement or window appears that says your computer is infected or that a unique plug-in is required. Without fully understanding what it is you're getting, you accept the prompt.
  2. When installing or updating a program, you're often asked if you want "additional software" to be installed. Often, this option is presented as a check box, which is already checked. So, if you click "Next" or "OK," the program considers that as permission, and installs the software — whether you want it or not. For this reason, be very careful when installing software. Make sure to read everything on every screen of the installation process before clicking any buttons.

When installing a program, you are given the options between an automatic and custom install. If you are installing something from the Internet, we suggest doing a custom install to make sure nothing else is added or changed during the install.

Downloading any infected software

Laptop downloading from the Internet.

When downloading any software (programs, utilities, games, updates, demos, etc.) via the Internet, make sure you're downloading the software from a reliable source. Be sure to run your downloads through your antivirus and spyware scanners upon completion. As we stated in a previous section, during the installation process, read all prompts about what the program is installing on your computer.


Verify if a website is reliable with tools such as WOT (Web of Trust).

Opening e-mail attachments

As a general rule, do not open e-mail you were not expecting to receive. Viruses enter the computer when users open e-mail attachments that contain malicious code. Even if the message is from a co-worker, friend, or family member, always use caution before opening a link or downloading an attachment.

Inserting or connecting an infected disk, disc, or drive

Any disk, disc, or thumb drive connected or inserted into your computer can be infected with a virus. As long as something is writable, a virus can move from a computer to that disk, disc, or drive. A common tactic used by hackers to access a network is by leaving out a thumb drive with malicious code on it. Then, when a user puts the thumb drive into their computer, it becomes infected with a virus or trojan horse.


This same rule applies to any networked drive or computer. If another computer has write access to a computer drive accessible by your computer, a virus can move between computers on a network.

Visiting unknown links

Mouse cursor clicking a hyperlink

Anyone, anywhere can create a website, which is great for humanity as an intelligent, creative, social species. But, it also means that any malicious person, anywhere, can create a website. Be aware of this when you visit a website for the first time, and you're unsure what it is.

A malicious website may have the capability to read files on your computer, transfer malicious files to you, or access your sensitive information. Always be cautious, and beware of any link you receive in chat, e-mail, or SMS (short message service).


A tactic commonly used with phishing is to make a link look like a legitimate link, but redirect you to a different page or may closely resemble a legitimate URL (uniform resource locator).

Not running the latest updates

Many of the updates, especially those associated with Microsoft Windows, are security oriented. Always keep your operating system and programs up-to-date. The plug-ins associated with your browser can also contain security vulnerabilities. To make sure you have the latest versions, run the Computer Hope tool to check installed plug-ins and their versions.

Open laptop disc drive tray

Pirating software, music, or movies

If you or someone on your computer connects to a file distribution network (e.g., BitTorrent), and copyrighted music, movies, or software is downloaded or shared, you may be at risk. Sometimes these files and programs contain viruses, spyware, trojans, or malicious software in addition to what you believe you are downloading.

No antivirus spyware scanner

If you're running a computer with Microsoft Windows, we highly recommended you have some form of antivirus and spyware or malware protection. This software can remove any existing viruses and spyware, and it helps prevent future attacks.