What is Computer Virus?
How It Works, Types and Prevention

A computer virus is harmful code that hides inside a normal file and runs when someone opens that file. It then copies itself into other files and computers, and it may delete data or slow a PC. It is one type of malware, and it needs a person to open or run a file.

Short Answer A computer virus is harmful code that attaches itself to a normal file or program and runs when someone opens that file. It then copies itself into other files, like a sticker on one library book that keeps appearing on every book it touches. It is one type of malware, and it cannot start until a person opens or runs a file. For example, one infected invoice opened on an office PC can spread the virus to a shared drive.

What is a Computer Virus?

A computer virus is a small piece of harmful code that hides inside another file, such as a document, a program or an email attachment. People call that file its host. The virus stays quiet until a person opens or runs the host file. Then it wakes up, copies itself into more files and may cause damage.

A virus is one type of malware, the general name for any harmful software. However, not all malware is a virus. In fact, the key sign of a virus is that it needs a person to open or run a file before it can do anything.

The name comes from biology. A flu virus needs a living body to grow, and then it spreads to other people. In the same way, a computer virus needs a host file, and then it spreads to other files and other computers. NIST, the US standards body, gives a similar meaning. It says a virus copies itself by attaching to other programs or files, then hides there until something starts it.

Key Words to Know

  • Host file: the normal file or program that a virus hides inside, such as a spreadsheet or an app.
  • Infected file: a file that now carries a copy of the virus.
  • Macro: a small set of saved steps inside an office document that automates a task, such as filling a table.
  • Payload: the harm a virus does once it runs, for example deleting files or showing pop-ups.
  • Quarantine: a locked area where security software keeps an infected file, so it cannot run or spread.
  • Endpoint: any device people use for work, such as a laptop, desktop or server.

How a Computer Virus Works

Most viruses follow the same basic life cycle. Knowing these steps helps you see where to stop one.

  1. It hides in a file: the virus sits inside a normal-looking file, such as an invoice, a song or a setup program.
  2. A person opens the file: someone downloads the attachment, opens the document or runs the program. Without this step, nothing happens.
  3. The virus runs: as the file opens, the hidden code starts working in the background. The file may still look normal.
  4. It copies itself: next, the virus adds copies of itself to other files on the same computer, on pen drives and on shared folders.
  5. It delivers the payload: finally, some viruses do harm right away. Others wait for a set date or action before they act.

So every infected file becomes a new carrier. As a result, when a colleague opens one of those files on another PC, the cycle starts again there.

Diagram of one infected invoice opened on an office PC, spreading to other files, a shared drive and two colleague PCs
A virus spreads only when people open infected files, so one shared drive can carry it to many PCs.

An Example From a Jaipur Office

Picture a small export firm in Jaipur. An accounts clerk receives an invoice file by email from what looks like a regular supplier. She opens it, and a fake message inside the file tells her to turn on macros to see the invoice. She follows it, and that lets a hidden macro run. The virus then copies itself into other spreadsheets on her PC. Later that day, she saves a few of those files to the shared office drive. The next morning, two colleagues open them, and their PCs pick up the virus too. By the end of the week, the shared drive holds dozens of infected files.

Types of Computer Virus

Security teams sort computer virus types by where they hide and how they start. The table below lists the common types in plain words.

Type Where It Hides and How It Starts
File infector Attaches to a program file and runs each time someone starts that program
Macro virus Hides in the macros of an office document, such as a Word file or an Excel sheet
Boot sector virus Hides in the part of a disk or pen drive that a computer reads first when it starts
Script virus Hides in a script, a short set of commands, inside a web page or an email attachment
Polymorphic virus Changes its look each time it copies itself, so simple scanners find it harder to spot

Macro and script viruses are the types to watch most closely in an office, because they arrive inside everyday files. Microsoft notes that recent versions of its Office apps turn macros off by default. Therefore, attackers now try to persuade people to switch them on, often with fake warnings inside the file.

Signs Your PC May Have a Virus

A computer virus often works quietly. However, it usually leaves some clues. Watch for these signs:

  • The PC becomes slow for no clear reason, or the fan runs hard while nothing is open.
  • Files change, grow in size, stop opening or vanish.
  • Strange pop-ups or new toolbars appear.
  • Programs crash or close without warning.
  • Your security software shows an alert or says it has quarantined a file.
  • Friends or customers say they received odd files from you.

One sign alone does not prove a virus, because old hardware or a full disk can cause the same problems. Still, if you see two or three together, tell your IT team and run a scan.

Computer Virus vs Worm and Trojan Horse

People often mix up viruses, worms and Trojans, because all three are harmful software. The difference lies in how each one gets in and spreads. A computer worm copies itself across a network on its own. In contrast, a Trojan horse pretends to be a useful program and does not copy itself.

Question Virus Worm Trojan Horse
Needs a person to open a file? Yes Usually no Yes, the person installs it
Needs a host file? Yes No No, it poses as its own program
Spreads by itself? Only when people open infected files Yes, across the network No

In short, a virus needs both a host file and a person. That is why careful habits from every staff member matter so much in stopping it.

How a Computer Virus Affects a Business

For a business, a computer virus can cause more than one slow PC. The effects usually grow with every shared file it touches.

  • Lost or damaged files: a virus can corrupt spreadsheets, delete records or make files unreadable.
  • Downtime: staff cannot work while IT cleans or rebuilds infected PCs, so orders and billing slow down.
  • Data leaks: some viruses copy data and send it to outsiders, which can expose customer details.
  • Spread to customers: infected files sent by email can reach clients and suppliers, which hurts trust.
  • A door for worse attacks: some viruses download other harmful software, such as ransomware that locks files and asks for money.

In India, a virus attack can also bring a duty to report. We explain this in the section on what to do below.

Talk to an ExpertWould your team spot a virus before it reaches the shared drive? Talk to our team about protecting every office PC.

Ways to Prevent a Computer Virus

No single step stops every computer virus. Instead, offices use several layers, so that one missed layer does not let the virus through.

Layers of Protection for an Office

  • Keep software updated: install updates for Windows, office apps and browsers soon after they arrive, because updates close known weak spots.
  • Use scanning software: antivirus software checks files as they open and blocks known viruses. Keep it switched on and up to date.
  • Protect every device: endpoint security watches all company laptops, desktops and servers from one place, so IT sees a problem early.
  • Turn off macros from unknown files: keep macros off by default, and never click “Enable Content” on a file you did not expect.
  • Scan pen drives: scan any USB drive before you open files on it, especially drives from print shops or visitors.
  • Back up files: keep regular backups in a separate place, so you can restore clean copies.
  • Train staff: teach people to pause before they open attachments. Many viruses arrive through phishing, fake emails that trick people into opening a file or link.
Layered defense diagram with staff care, macros off, updates, scanning, endpoint protection and backups around company files
Each layer stops some viruses, so one missed layer does not expose every file in the office.

Built-In Protection on Windows

Microsoft Defender Antivirus comes built into Windows 10, Windows 11 and versions of Windows Server. It scans files in real time and can quarantine a virus it finds. For companies, it also works with Microsoft Defender for Endpoint, so the IT team can see alerts from all devices in one place. Microsoft also says modern security software, such as Microsoft Defender Antivirus, should be able to detect and block known macro viruses. It works best when Windows updates stay current and staff check attachments before they open them.

What to Do If You Find a Computer Virus

If you think a PC has a computer virus, stay calm and act in order. These steps limit the spread and protect your data.

  1. Disconnect: unplug the network cable or turn off Wi-Fi on the PC, so the virus cannot reach shared drives.
  2. Tell IT: report it to your IT team or service partner right away, and say which files you opened. In India, your company may also need to report it to CERT-In within 6 hours, so do not wait until the cleanup ends. You can email incident@cert-in.org.in or call 1800-11-4949.
  3. Run a full scan: in Windows Security, a full scan checks every file and program. Microsoft also offers an offline scan. It restarts the PC and checks it before Windows fully starts, which helps catch a virus that a normal scan misses.
  4. Restore clean files: replace damaged or infected files with copies from a backup taken before the infection.
  5. Change passwords: change important passwords from a different, clean device, in case the virus captured them.
  6. Check other PCs: scan the shared drive and any computer that opened the same files.

For a larger outbreak, follow your company’s incident response plan, the agreed steps for handling a security attack.

Reporting to CERT-In in India

In India, CERT-In (the Indian Computer Emergency Response Team) is the national agency for cyber incidents. Its directions of 28 April 2022 list “spreading of virus” among the incidents that companies must report. The same rule covers government bodies, data centers, service providers and intermediaries, such as internet and telecom companies and online platforms. They must report within 6 hours of noticing the incident or being told about it. The email and phone contacts in step 2 come from these directions. So keep these contacts in step 2 of your plan, because the 6 hours start when someone first notices the virus.

Frequently Asked Questions About Computer Virus

What is the definition of a computer virus?

A computer virus is a type of harmful program that copies itself by adding a copy of its code to other programs or files. It then hides there until someone opens or runs that file. This matches the plain meaning in the NIST glossary. Many viruses also cause damage, and some wait for a set date or action before they act.

How do viruses spread from one computer to another?

Viruses spread when people share and open infected files. Common paths are email attachments, files on pen drives, downloads from unknown websites and documents saved on a shared office drive. Each time a person opens an infected file on a new computer, the virus can copy itself there too. So careful habits with files and attachments slow the spread a great deal.

How can a computer virus affect your computer?

A computer virus can make your computer slow, crash programs, change or delete files and show strange pop-ups. Some viruses use up disk space or memory by copying themselves again and again. Others quietly copy data such as saved passwords and send it out. A few also download other harmful software, which can lead to a bigger attack on the whole office.

Can a virus destroy computer hardware?

In almost all cases, no. Most viruses damage software and data, such as files, settings and programs, not the physical parts of a computer. However, a virus can make a PC so unstable that it seems broken, and it may stop the computer from starting. Usually, IT can fix this by cleaning or reinstalling the software and restoring files from a backup.

Does Windows have built-in virus protection?

Yes. Microsoft Defender Antivirus is built into Windows 10 and Windows 11, and it is available for versions of Windows Server. To check it, open the Windows Security app and select Virus and threat protection. There you can see if protection is on, run a quick or full scan and check for updates. In a company, IT can manage these settings for every PC.

Is every computer virus harmful?

Yes, every computer virus causes some harm, even when it does nothing visible. It copies itself without permission, changes files and uses up storage and memory. Some viruses wait quietly for a set date or action before they show their real payload. So treat any virus alert as serious, disconnect the device, and ask your IT team to check it before you keep working.
Use CaseImprove Threat Detection and Response

References

  1. Definition of a virus: NIST Computer Security Resource Center, Glossary: Virus
  2. Macro viruses and Microsoft Defender Antivirus: Microsoft Support, Protect yourself from macro viruses
  3. CERT-In 6-hour reporting rule: CERT-In, Directions under section 70B(6) of the IT Act, 2000 (28 April 2022)
Stay Updated

Get the Latest Terms & Insights.

New encyclopedia terms, threat intelligence, and architecture decisions, by email.

Book a Consultation

A practice principal will contact you within 1 business day.

Thank you! A Signisys principal will be in touch within 1 business day.