Knowledge Base
Browse Docs
  • Introduction
    1. DefensX
    2. DNS & Web Filtering
    3. Zero Trust Files
    4. Zero Trust Credentials
    5. ADWare Protection
    6. Remote Browser Isolation
    7. Secure Browser Extension
    8. Secure Mobile Browser
  • Management
    1. Role-Based Access Control
  • Deployment
    1. Deployment via RMM
    2. Operating System Agent
    3. Deployment via GPO
    4. Deployment via Intune
    5. VDI and Terminal Servers
    6. Windows Manual Deployment
    7. Mac MDM Deployment
    8. Mac Manual Deployment
    9. Network Deployment
    10. Secure Mobile Browser
    11. Bypass Option
    12. AI Protections
    13. SaaS Restrictions
    14. Bookmark Manager
  • Secure Access (ZTNA)
    1. Configuration
  • Integrations
    1. Azure AD
    2. Identity Providers
    3. SIEM
  • Policy Management
    1. Configuring Policies
    2. Configuring Consents
  • Questions & Answers
    1. Licensing
    2. Incognito Mode
    3. Onboarding
    4. Active Directory
    5. Group Synchronization
    6. Agent
    7. Conflicting Softwares
    8. Reporting
    9. Virtual Desktops
    10. Using the Backend
    11. DNS & Web Filtering
  • Training Videos
    1. Onboarding Videos
    2. Attack Scenarios
    3. MSP Admin Training Series
  • MSP Automation
    1. Overview
    2. External Notifications
    3. Integrations
    4. Partner API
ONLINE DOCUMENTATION

Fixing MSI upgrade problem in Windows

In this document
  • What is the MSI upgrade issue?
  • Is it specific to DefensX?
  • How can we solve this problem?

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
www.defensx.com
Secure Industries, Inc 101 Avenue of The Americas, Floor 9 New York, NY 10013