Setting up ADB and Fastboot for your operating system is outside the scope of this how-to.
We assume you have ADB and Fastboot setup and in your PATH.
To Unlock Bootloader
adb shell
su
echo -ne "HTCU" | dd of=/dev/block/mmcblk0p3 bs=1 seek=33796
exit
adb reboot bootloader
verify unlocked
To lock Bootloader
adb shell
su
echo -ne '\x00\x00\x00\x00' | dd of=/dev/block/mmcblk0p3 bs=1 seek=33796
exit
adb reboot bootloader
verify locked
Bootloader unlock XDA reference for m7vzw
Decrypted RUU's and other goodies can be found here
Flash stock firmware using the following process.
Verify you have a locked bootloader.
Enter RUU mode
Fastboot oem rebootRUU
Flash the decrypted RUU renamed as a zip file.
Fastboot flash zip Rom.zip
If you get the following error run the same command again until it succeeds.
FAILED (remote: 90 hboot pre-update! please flush image again immediately)
Once you successfully flash the RUU, exit RUU mode and reboot into the bootloader.
Fastboot reboot-bootloader
Only do this if you no longer require S-OFF and have a stock firmware signed by HTC. You have been warned...
Write secure Flag i.e. S-ON.
fastboot oem writesecureflag 3
Verify this was successful. You should get a message similar to the following.
“(bootloader) writesecureflag: partitions signature pass
OKAY [ 1.666s]
finished. total time: 1.666s”
Reboot into the bootloader.
fastboot reboot-bootloader
Verify you are S-ON and type
fastboot reboot
Congratulations. You are now 100% stock. I would advise against writing the secure flag(S-ON) unless you have a good reason to do so. Locking your bootloader and returning to stock firmware is all you need for most HTC warranty purposes.
Verify your device state if you are interested.
Fastboot getvar all
Credit to XDA for this stuff