Download tgz image file from Factory Images for Nexus Devices
Extract it, copy adb.exe flashboot.exe (from Android SDK) to same directory
adb devices (to check if device detected)
adb reboot-bootloader (or Press and hold Volume Down and Power buttons at the same time when poweroff)
fastboot devices (to check if device detected)
flash-all.bat
[F:\Nexus5]flash-all.bat
sending 'bootloader' (2579 KB)...
OKAY [ 0.197s]
writing 'bootloader'...
OKAY [ 0.485s]
finished. total time: 0.684s
rebooting into bootloader...
OKAY [ 0.111s]
finished. total time: 0.112s
sending 'radio' (45521 KB)...
OKAY [ 1.547s]
writing 'radio'...
OKAY [ 3.130s]
finished. total time: 4.678s
rebooting into bootloader...
OKAY [ 0.120s]
finished. total time: 0.120s
archive does not contain 'boot.sig'
archive does not contain 'recovery.sig'
archive does not contain 'system.sig'
--------------------------------------------
Bootloader Version...: HHZ12d
Baseband Version.....: M8974A-2.0.50.2.21
Serial Number........: 03a16120251a42b9
--------------------------------------------
checking product...
OKAY [ 0.100s]
checking version-bootloader...
OKAY [ 0.099s]
checking version-baseband...
OKAY [ 0.099s]
sending 'boot' (8852 KB)...
OKAY [ 0.489s]
writing 'boot'...
OKAY [ 0.754s]
sending 'recovery' (9552 KB)...
OKAY [ 0.545s]
writing 'recovery'...
OKAY [ 0.794s]
sending 'system' (981596 KB)...
OKAY [ 30.979s]
writing 'system'...
OKAY [ 66.585s]
erasing 'userdata'...
OKAY [ 11.858s]
erasing 'cache'...
OKAY [ 0.549s]
rebooting...
finished. total time: 113.261s
Press any key to exit...
If got error: update package missing system.img
Unzip image-*.zip
If stuck in boot logo screen (wait 10 minutes, still in boot logo screen),
flash CWM recovery,
Download img from here
adb reboot-bootloader
fastboot flash recovery recovery-clockwork-touch-6.0.4.5-hammerhead.img
enter Recovery mode
mounts and storage -> Format /data and /data/media (/sdcard)