Installing HP Printer Driver for XP/Vista/7 in Windows 10/8.1/8

Recently I swallowed the bitter pill and finally upgraded to Windows 10. It's during the subsequent installation of the drivers and softwares that I hit a snag with the HP Printer Software and Driver. Apparently my computer did not meet some system requirements.

The HP printer in question here was a budget model, the HP DESKJET 2515 ALL-IN-ONE which seems to date back to 2012 before the release of Windows 8. The driver installation DVD it came with is clearly labelled that the software is compatible with Windows XP, Vista and 7, but I thought to myself that it should work on Windows 10. Well, I was wrong.

Launching the setup gave me this error:
HP Printer Driver Intstallation Error
HP Printer Driver Intstallation Error

Seeing this I did the most obvious thing people do in this situation - I copied the installation files from the DVD into a folder in my hard drive and set the compatibility of the setup.exe to Windows 7. I then run the software but still it gave me the same error. After this, I figured out I could just check the HP Support website for an updated driver package but at the time I had no internet and to complicate matters I wanted to use the printer for something urgent.

Somehow I was confident that the package should install so I just started troubleshooting and the first thing I checked was the installation log that had been dumped in the AppData folder:
Checking the log revealed that the setup.exe wasn't doing the actual installation rather it was calling some MSIs to install the software. So changing the compatibility settings for the setup.exe had no effect on this MSIs. So I figured I should just change the compatibility settings for this MSIs instead and fortunately after doing this the driver and software installed with no hiccups.
Software Selections
Software Selections After Setup Went Through

The MSIs in question were:

DisplayName: HP Deskjet 2510 series Basic Device Software

DisplayName: HP Deskjet 2510 series Setup Guide

DisplayName: HP Deskjet 2510 series Product Improvement

HP2510\Optional\HP Update.msi
DisplayName: HP Update

DisplayName: HP Deskjet 2510 series Help

So if you're facing a similar issue, basically go and change the compatibility settings for these MSIs (*.msi) in the installation folder to Previous Versions of Windows. To do that;

1. Right-click on the MSI then choose Properties

2. In the Properties window switch to the Compatibility tab

3. Under compatibility mode, add a checkmark on where it says Run this program in compatibility for: then select Previous Version of Windows
compatibilty mode
Compatibilty Mode Settings

The exact MSIs will vary depending on your printer and the version of Windows (32/64 bit) you're using. I'm on Windows 10 x64 so that's why the MSI's have the x64 appended to their filenames. You can check the logs in [C:\Users\username\AppData\Local\HP\AtInstall] if you're not sure what to change but if you have the time, just do it for all the MSI  (*.msi) files in the folder and subfolders. They're not that many.

So hopefully that should solve your problem. By the way, the printer is functioning pretty well just as it did in Windows 7.