How to do a factory reset in Windows 7.
That depends on the device. By default there is no factory restore/reset, you can only format the hard drive/partition and reinstall Windows from the CD/DVD.
Some devices, primarily mobile ones, do have a hidden recovery partition that allow you to restore the device to it's factory (pre-installed) state.
Some devices, mostly branded Desktops, do ship with a recovery CD/DVD that allows you to restore the hard drive to the factory (pre-installed) state.
On some occasions the restore/recovery options require the user to manually create a restore media, preferably after the first boot of the device. Generally you can do that at any later time, however, issues present at that time are likely to be "present" on the recovery media and re-occure after a restore.
if it is a laptop then there is factory reset hidden partition, you can use that to reinstall windows. If it is a pc then you need the windows 7 cd you can boot on it and choose upgrade option (you have to activate windows 7 again depending on the license type it may not work or you have to activate via phone.