[Desire HD General] Quinny899:
When returning to stock, I found this the most simple way to do it.

You will need:

AAHK

Your carrier's branded RUU (I'm using the Orange UK one found here

A computer with Windows on it (Annoying, I know), however this is just needed for the RUU exe process, not for AAHK

Disclaimer: I'm not responsible for anything you do to your device! I recommend making a backup of AAHK's file you will be editing

before

you start editing it

1. Download and open AAHK, entering the passcode (read the manual)

2. Type "o" and press enter

3. Type "s" and press enter

4. Find the closest generic RUU to your device, but DO NOT SELECT IT

5. Remember the CID of the one you chose (for me it's HTC__001, as I chose the UK generic one)

6. Close the terminal

7. Select your respective file that runs AAHK (.sh for Linux, .cmd for windows [I think])

8. Open it in a text editor

9. Use a find tool within the file to find the CID of your closest generic RUU, which should look a little like this:

elif [ "$inp" = "0" ]; then
cid="HTC__001"
dlFlash

10. Find your CID for your carrier, this thread is very useful: http://xdaforums.com/showthread.php?t=1195475

11. Change the CID within the AAHK text file, to match your carrier's CID, for example my carrier's CID is ORANG001, so my text would now read this:

elif [ "$inp" = "0" ]; then
cid="ORANG001"
dlFlash

12. Save and close that file

13. Open AAHK in a terminal again, entering the passcode and then selecting "o" and "s"

14. Go to your generic RUU again (Don't worry that the CID hasn't changed in the terminal, it will have done in the code)

15. Now select that RUU, and let it download, but DO NOT YET SELECT FLASH "y", and DO NOT CLOSE AAHK

16. Download this PD98IMG http://cmw.22aaf3.com/ace/stock/1.32.405.6/PD98IMG.zip

17. Copy it to your AAHK folder, within the folder named PD98IMG, where there will be the one you just downloaded

18. Select the one that AAHK downloaded(will be called something like "PD98IMG_GB2" and rename it to "BACKUP_ZIP"

19. Select the one you just downloaded from my link, and rename it to what you just renamed the other one from, so it will be something like "PD98IMG_GB2"

20. Return to AAHK, that you left open, and now select "y" to flashing the RUU and "y" to setting S-ON

21. Wait for the phone to finish rebooting, returning to the stock, unbranded froyo RUU. You're not done yet.

22. When the phone is done turn on USB debugging, open a second terminal and run

adb shell getprop ro.cid

It should return your carrier's branded CID. If not, you did something wrong, re-root using AAHK and do the process again. ONLY IF IT does, then continue

23. Now you need to flash your branded RUU. If you need to, boot a Windows computer now and download it. Else, just open it

24. Accept everything it says about readmes and things, if you're nervous, read them

25. Let it flash, once it's done it should reboot the device

26. Again, enable USB debugging, open a second terminal and run:

adb shell getprop ro.cid

If it returns your carrier's branded CID, you're good, continue. Else, re-root and start again

27. Your phone should now prompt a software update if the RUU is older than the current version, accept and install these

28. Hit the thanks button, it took me a while to figure out and put this together

Thanks to attn1 for the AAHK, Chris Moyles for the Toby Lerone references on radio stations and Real Radio Northwest for providing me with background music for most of the time I was writing it.

You are done, now go do whatever you were going to do, whether it be warranty or trading it in