For obtaining Windows 10 installation/recovery media for free you can use Windows 10 Media Creation tool from Microsoft in 32-bit and 64-bit variant. The tool allows creation of bootable Windows 10 installation DVD/USB or allows the download of a Windows 10 ISO which you can burn later to DVD/USB or use for fast image deployment with dism utility (I recommend this method of installation as it has several advantages).
For the time of writing this notes (July 2015) you can download free and create Windows 8.1 installation(and recovery) media using Windows 8.1 Media Creation tool from Microsoft. The tool allows creation of bootable Windows 8.1 installation(and recovery) DVD/USB or simply a Windows 8.1 ISO.
If you have a Windows 8 retail key you can download Windows 8 for upgrade/installation.
If you have a legitimate Windows 7 retail key you can download Windows 7 for installation (and recovery).
Windows XP is out of support so there is no official free download for it from Microsoft but you can obtain it semi officially through download Windows XP (or Vista, Win 7/8/8.1) installed in a Virtual machine for Hyper-V, VirtualBox or VMware (for example Windows XP with IE8, Hyper-V 2012 installation).
Note from 27 mar 2017: XP and Vista VM's are no longer available from Microsoft.
You can download Windows 10/8.1/8 Enterprise Evaluation versions and use them for repairing Windows 10/8.1/8 boot with the manual method outlined below. You have to register for the download using your Microsoft account.
I do not use unofficial distributions of Windows as there is no guaranty that some malware is not included in the download but if you are desperate finding your Windows version and it is not listed above you can download Windows 10 to Windows XP (32-bit and 64-bit versions) from GetIntoPC. Some of the downloads claimed to be copies of untouched official Windows distributions. (It is advisable to try to find the official SHA-1 hash of the downloaded ISO and check it! Google for SHA-1 or SHA1 and Windows version you downloaded - for example "File Name: en_windows_vista_sp2_x64_dvd_342267.iso Languages: English SHA1: AAEE3C04533899F9F8C4AE0C4250EF5FAFBE29A3")
Media creation tool for Windows 10/8.1/8 can create installation DVD or USB.
For creating installation USB from ISO most sites suggest "Rufus" tool.
There are many tools for transfering ISO to DVD.
1. Boot from installation/recovery media.
2. Select recovery - Startup(automatic) repair.
3. You have to repeat steps 1. and 2. up to three times with rebooting after each run to successfully repair booting. The repeated runs are necessary as not all boot problems can be fixed on a single run.
You have to check (using Disk Management or diskpart.exe) that there is a primary partition marked as active on your first disk which holds (or will receive) boot related files. The existence of active primary partition on MBR style disks is crucial for Windows booting! If there is no active partition you should mark a primary partition as active (Fix 2) and run Startup repair again.
You have to check (using diskpart.exe) that there are two necessary system partitions present on first disk: 1) EFI System Partition(ESP) which holds (or will receive) boot related files. 2) MS Reserved partition. The existence of both mentioned partitions on GPT style disks is crucial for Windows booting! If there is no ESP and/or MS Reserved partition present on disk you should create the partition/s and run Startup repair again.
Aways make a backup of current BCD first so you can restore it!
Following commands will re/create BCD on system drive which is mapped to drive N: (change drive letter to reflect your mappings)
bootsect /nt60 N: /force /mbr - rewrite Windows 7/8/10 boot records to system partition and MBR. attrib -s -h N:\boot\bcd - remove system and hidden attributes of BCD file so it can be deleted. See Note below. del N:\boot\bcd - delete BCD. See Note below. bcdboot c:\windows /s N: - re/create BCD assuming your latest Windows version is installed on drive c:
Note: On UEFI firmware boot records are not used for booting anymore but it does not harm to refresh them. On UEFI/GPT disk path to BCD is "\EFI\Microsoft\boot\BCD"!