A computer virus was a self-replicating program, usually designed with the intention of causing damage to or otherwise altering computer systems. The nomenclature originated from a pathological virus in the sense that a virus reproduced and caused harm to its host.
In 2154, the warp matrix of the Enterprise was compromised by a subroutine planted by a group of Klingon Augments. The subroutine also compromised the starship's command protocols. (ENT: "Affliction", "Divergence")
Prior to his open defection to the Maquis in 2372, Michael Eddington planted cascade viruses in Deep Space 9 and the USS Defiant's computers. This allowed him to disable the Defiant at a critical time. Fortunately, Odo was able to find and delete the one in the station's computers before it could be activated. (DS9: "For the Uniform")
Also during that year, when the missile Cardassian ATR-4107 ("Dreadnought") accidentally targeted Rakosa V, part of B'Elanna Torres' plan to disable it involved activating a Cardassian back-up file that was part of the missile's original systems. The new systems reacted to it by initiating a counter-virus response program and although they were eventually able to neutralize it, the time spent doing so provided Torres with the distraction she needed in order to gain access to an area where she could destroy the missile. (VOY: "Dreadnought")
Later that year, Harry Kim suggested that The Clown might be a computer virus of some sort, unaware that he was actually a malevolent manifestation of the fears of members of Viorsa's species who had been trapped in the neural network. The Clown mocked him for this suggestion and commented that he had a "mind full of technical and operational thoughts and ideas." (VOY: "The Thaw")
Ramuran tracers use computer viruses to eliminate any records of their presence from alien ships. Both of the USS Voyager's encounters with the Ramurans in 2374 were erased in this manner. (VOY: "Unforgettable")
In 2380, when the USS Cerritos had been seriously damaged by a Pakled ship, Ensign Sam Rutherford activated the holographic program "Badgey" and disabled holodeck safety protocols so that Badgey could create a computer virus to disable the attacking vessel. After Peanut Hamper refused to deliver the virus, Rutherford volunteered, and Lieutenant Shaxs carried him through the melee with Pakled boarders to the Cerritos' repair bay. There, Shaxs commandeered the shuttlecraft Sequoia and flew to the Pakled ship, where Rutherford began to upload the virus. Unfortunately, Badgey had programmed the virus not to upload completely until after Rutherford was dead. Badgey then initiated a self-destruct process on the vessel, hoping to kill Rutherford, but Shaxs saved him by ripping out his cybernetic implant and sending him out of the exploding vessel on the Sequoia. (LD: "No Small Parts")