How can I repair the Windows 8 EFI Bootloader?

I installed Windows 7 and Windows 8 in EFI mode on a hard disk some days ago. Today, the bootloader got missing/corrupted.

I currently have the Windows 8 installer on a flash drive and tried using the Automatic Repair option to repair the bootloader but it didn't do anything. The Startup Repair option is also missing in the Windows 8 installer.

How I can repair/recreate the EFI bootloader from the Command Prompt?

BCDEDIT returns the following message:

The requested system device cannot be found.

I've spent a lot of time trying to get my Windows 8 PC to boot again after cloning to a new SSD and try to summarise how I finally got it all working -

Firstly, boot from a UEFI Windows 8 recovery disk (CD/DVD/USB) - I found that the automated recovery process didn't find the correct Windows partition, nor when I managed to add it to BCD settings would it make it reliably bootable e.g. using BCDEDIT I got it to find and launch the Windows partition but it refused to cold boot or would not "keep" the settings after a 2nd reboot or power off.

Go into the Advanced options and run the Command Prompt.

Enter diskpart to use the DiskPart tool to ensure you have all the right partitions and to identify your EFI partition - the key thing here is that your EFI partition is formatted as FAT32:

DISKPART> sel disk 0

Disk 0 is now the selected disk.

DISKPART> list vol

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
  Volume 0     E                       DVD-ROM         0 B  No Media
  Volume 1     C                NTFS   Partition    195 GB  Healthy    Boot
  Volume 2         WINRE        NTFS   Partition    400 MB  Healthy    Hidden
  Volume 3                      FAT32  Partition    260 MB  Healthy    System

Then assign a drive letter to the EFI partition:

DISKPART> sel vol 3

Volume 3 is the selected volume.

DISKPART> assign letter=b:

DiskPart successfully assigned the drive letter or mount point.

Exit DiskPart tool by entering exit and at the command prompt run the following:

cd /d b:\EFI\Microsoft\Boot\

bootrec /fixboot

Delete or rename the BCD file:

ren BCD BCD.bak

Use bcdboot.exe to recreate BCD store:

bcdboot c:\Windows /l en-gb /s b: /f ALL

The /f ALL parameter updates the BIOS settings including UEFI firmware/NVRAM, /l en-gb is to localise for UK/GB locale. The localisation defaults to US English, or use en-US.

Reboot and cross your fingers.

This gave me headaches. I was going in circles for a long while. There isn't a lot of reliable info about fixing UEFI/Windows 8 at the time of writing.

[EDIT]

To re-enable Hyper-V, I also had to run the following from an Administrator Command Prompt within Windows after rebooting:

bcdedit /set {default} hypervisorlaunchtype Auto
bcdedit /set {default} nx OptIn

The other answers are helpful but this is what I had to do to fix mine.

I had a 1.5 TB hard drive with Windows 7 installed on it. I then installed Windows 8 onto a 150 GB SSD I bought. The 1.5 TB hard drive failed and I could hear it making a noise, my computer would no longer start, saying "please insert system disk". I thought that the bootloader was missing as it must have been on the 1.5 TB disk. It turns out it was but the problem then was the guides I followed would not rebuild the bootloader or whatever it is called as i did not have an EFI partition on the smaller 150 GB disk (this may have existed on the failed disk), it only had 1 partition which filled the entire disk.

I did not want to lose all my data so I entered the Command Prompt by booting from my Windows 8 install USB drive (noting that you cannot boot the UEFI version of this if that appears, select to boot from the just the USB drive without the UEFI appearing before it).

Once in Command Prompt (see the other answers for instructions) you need to shrink the partition. To do this, enter the following commands, pressing Enter after each one:

diskpart

list disk

select disk 0

list partition

select partition 1

shrink desired=200 minimum=200

create partition efi

list partition

select partition 2

format fs=fat32

These commands will create the EFI partition. Double-check everything by typing list vol. You should see a 200 MB partition. You now need to assign it a letter. Do this by typing assign, then list vol again to see what letter has been assigned.

Now this is done you need to copy the boot files to this newly created partition:

bcdboot C:\Windows /l en-gb /s B: /f ALL

Note: you must replace C: with the drive letter of the partition that contains Windows, and B: with the letter assigned to the EFI partition you just created.

I also entered the following commands:

bootrec /fix

bootrec /fixmbr

These both came back successful, no idea if they really did anything but who cares. Windows is now fully recovered.