Cannot install SharePoint CU

I recently got this error when trying to install a SharePoint CU (KB5002629) on SharePoint Subscription Edition. This is a corrupt C:\Windows\Installer folder, or maybe someone deleted some of the files/folders from this directory to save space. You should NEVER do that!! This is the error that was popping up. I tried some older CU's and got the same error.

To fix this issue you need to update the C:\Windows\Installer folder from a working server. Luckily I have a PROD and the DEV was the issue, so I was able to fix this using a script that someone kindly created.

The Script is here: This script was designed as a fix Windows "Installer" by restoring the missing Package(*.msi)/Patches(*.msp) files with the following steps: 1. Identifying the missing files. 2. Crawl the missing files from specified folder or other healthy machine. · GitHub

Someone wrote a nice blog here to explain the solution. Using PowerShell to restore Missing Windows Installer cache items (schottsql.com)

 This script pulled missing files from the working sharepoint installer .\Restore-InstallerFiles.ps1 -SourceFolder "D:\InstallerFiles", "E:\InstallerFiles", "\MachineX\D$\MSI Files";