If you have Windows 10 use the reset option in Settings.
Use the recovery discs that possibly came with the PC.
Look for a 'recovery' or 'backup' Compaq or HP software that might be loaded on your PC & open it. When you're in it you should have an option to burn recovery discs (you'll need blank CD or DVD's). While disc 1 is inserted & from a fresh power-on tap a key when it prompts you to (else you may have to press a F9, F10, F11, or F12 to get a boot menu to select the CD drive)
Use F12 (or F9, F10, F11) to boot into recovery environment to factory reset