Browse Docs
Fixing MSI upgrade problem in Windows
What is the MSI upgrade issue?
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.
Is it specific to DefensX?
No, this process is not specific to DefensX. It applies to all software packages distributed as MSI (Microsoft Installer) files. The same problem can seen on even the Microsoft SQL Server described here: https://learn.microsoft.com/en-us/troubleshoot/sql/database-engine/install/windows/restore-missing-windows-installer-cache-files
The directory mentioned, %windir%\Installer
, serves as a cache location for Windows installer-based applications. It contains stripped-down versions of the Windows installer data files. During installation, updating, or removal of an application, this directory is utilized by the application to verify the existence of previously installed items and determine the necessary steps for the installer to take next.
The files stored in this directory are unique to each machine. Therefore, attempting to delete these files and replace them with copies from another machine would be inappropriate. Removing items from this directory can potentially lead to application crashes or, in severe cases, require the reinstallation and patching of the affected application.
How can we solve this problem?
The only solution is to download the same MSI file into the same location with the same name.
Due to the cached names being different from computer to computer, they must be queried through registry or Powershell and should be copied with the correct name.
To download the original DefensX Agent MSI file to the correct location easily;
-
run a Powershell as Administrator
-
copy and paste the following commands as a whole in the Powershell window
# Check if the DefensX Agent msi file is exist, if not try to download it
$program = Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -eq "DefensX Agent" }
if ($program -ne $null) {
# Check if the LocalPackage exists in the filesystem
if (Test-Path $program.LocalPackage) {
Write-Host "DefensX Agent is installed and LocalPackage exists. No need to download."
} else {
# Define the URL for downloading the latest version
$downloadUrl = "https://cloud.defensx.com/defensx-installer/latest.msi?v=$($program.Version)"
Write-Host "Downloading DefensX Agent version $($program.Version)..."
$ProgressPreference = 'SilentlyContinue'
$response = Invoke-WebRequest -Uri $downloadUrl -OutFile $program.LocalPackage -UseBasicParsing
if ($response.StatusCode -eq 404) {
Write-Host "This version ($($program.Version)) doesn't exist on cloud. It can't be downloaded"
} else {
if (Test-Path $program.LocalPackage) {
Write-Host "DefensX Agent installer downloaded successfully to: $($program.LocalPackage)"
} else {
Write-Host "Failed to download DefensX Agent installer."
}
}
}
} else {
Write-Host "DefensX Agent is not installed."
}
Note
|
You can also create a Powershell script and run it. But if you received an error like Restricted Execution Policies , you need to execute Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process command first to allow running the script for the current Powershell session. Or you may run the script as: powershell -ExecutionPolicy Bypass -File scriptname.ps1
|