First off never install anything on your computer from a website unless you trust the site. This seems pretty straight forward but a lot of flashy sites out there look legitimate, when all they are doing is hosting a virus, spyware or something equally bad for computer. The easiest way for them to do this is to make it seem like something you really need. That flashy program that just popped up asking you to scan your computer so benignly for virus or spyware is actually just spyware. Almost 99% of the time it will hijack your computer and ask you to pay to have them fix the problem, which ironically is the program you just installed on your computer.
Second watch what sites you're visiting, people oddly think that the only sites that have viruses or spyware are porn sites, and while they do host the majority of them, a lot of sites out there, gossip, television or movie sites etc... also are hosting some very bad things for your computer. First rule if you are going to visit a site try checking online to see if it's actually a legitimate and safe site. The easiest way to do this is by downloading McAfee's Site Advisor here.
Now if you clicked the "here" that's also a clever way people get you to download viruses but I didn't so your safe this time but be careful what links you click on.
Third get a good virus scanner and use it, use it a lot! Once a week is usually good enough but setting it up to run at least every night is better. In fact never restart your computer until you have scanned it. The best program out there hands down is Malwarebytes which you can get for free here click the link for the free version, though I encourage you to buy the full version! Malwarebytes is one I keep in my arsenal at all times. You can also get, totally free, Microsoft's security essentials which is a good back up (found here.) Run both of these as often as you can to ensure your safe.
There are others and you will see them but before installing any virus scanner please use McAfee's Site Advisor to make sure it's a legitimate site. Don't screw yourself by doing the one thing you're trying to avoid.
In closing if you do get a virus or spyware on computer and you know it's there never restart your computer until you run one of the two above. Sometimes a virus or adware might be keeping you from running Malwarebytes or Security Essentials if that's the case then run this little program, RKill found here. This will stop almost any virus running and allow you to run a scan.
Now if you have restarted your computer and cant get anything to work reboot your computer and when the computer starts to turn on keep pushing the "F5 key" till you get a prompt asking you if you would like to boot into safemode. When that comes up do it! If you can, go into "safemode with networking" and then follow the steps I told you. Run Rkill then Malwarebytes then Security Essentials (separately don't be lazy.) Once they have gotten rid of any virus you might have, go to your (windows/start button) where all your program menus are and choose the help and support from the menu. From there you will see an option to restore your computer. From there look through the points and choose a date where you know your computer was virus free and go to that point. Some people are afraid to do this cause they fear they might lose some documents or what not on their computer but the only thing this will do is remove any programs you have installed or that have installed with out your knowledge from your computer (well it does more but I don't want to geek this all up.)
God willing your computer is as good as new. So that's it. I just put a lot of those IT guys out there out of work by showing you just how simple it is. I hope this helped and keep tuned in I'm going to be blogging more again so you might read something else helpful! Who know's it could happen!