In any scenario where an MSI package is upgraded, the MSI file containing the currently installed version must remain on the system.
During installation or upgrade, a copy of the MSI file is stored in the %windir%\Installer
folder by Windows, typically with a randomly generated name such as 74f06.msi. Although the exact file name cannot be predicted, it can be queried through the registry or PowerShell.
During the upgrade process, the uninstallation section of the MSI file corresponding to the currently installed version is executed first. If the cached MSI file in the %windir%\Installer
folder is deleted for any reason, Windows cannot execute the MSI for the current version, leading to difficulties in upgrading or uninstalling the MSI properly.
In such cases, Windows also attempts to locate the original MSI file as a last resort. For example, if an MSI file like C:\Windows\Temp\Example-1.0.msi was downloaded and its cached version under the %windir%\Installer
folder is removed, the process can still proceed if the original file remains in its original location (as indicated in the Windows Registry).
However, if both the cached and original files are removed from the system, upgrading or uninstalling the software becomes impossible.