The question with failed MSI package uninstalls causing further installation attemts return error 2908 in the MSI logs (msiexec returns 1603) have come up in very many different forums so I just wanted to give my solution to this since we have had it appearing now and then over the years and I have never seen a programmatic solution to it.
The general cause is that the MSI uninstaller creates "orphaned keys" in the registry in the LOCALMACHINE hive under SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components
The typical MSIEXEC log errors looks like this:
MSI (s) (2C:0C) [14:52:21:490]: Note: 1: 1401 2: UNKNOWN\Components\B44598ECC622C01BD780AEC8E234E3E1 3: 5 DEBUG: Error 2908: Could not register component {CE89544B-226C-B10C-7D08-EA8C2E433E1E}. MSI (s) (2C:0C) [14:52:21:523]: Product: Some software 3.7 -- The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2908. The arguments are: {CE89544B-226C-B10C-7D08-EA8C2E433E1E}, ,
As other posts have pointed out you can locate the keys from the MSI log file and edit them with Regedit, do "properties" and "advanced", change their owner from "unable to display current owner" (or similar text) to "Administrators" and finally set the access rights on it, like instructed in this link:
https://kb.acronis.com/content/33458
However, this is cumbersome, you can get hundreds of broken items. Worse, the above manual procedure seems to have issues in Windows 10 and there is no more "Windows Fixit" tool available.
So how to fix this automatically? These "broken" registry keys are hard to change even as an elevated admin resulting in various errors, thus to be sure of success I run it as a service in a SYSTEM account.
I thus created a windows service project in visual studio running as SYSTEM (SID S-1-5-18), then we open the parent key of the offending entries:
RegistryKey hklm = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64); RegistryKey regParent = hklm.OpenSubKey( "SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Components", RegistryKeyPermissionCheck.ReadWriteSubTree, RegistryRights.FullControl);