A Reliable Detection Method for Mozilla Firefox for MECM (SCCM)… or other programs that launch a separate uninstaller

It would appear Firefox is one of those applications that comes with a half-baked MSI installer. You can install Firefox with msiexec, but that’s where it stops. No repair, no uninstall, no product detection. This, of course, makes deployment with Microsoft Endpoint Configuration Manager (SCCM) a little bit trickier.

The challenge lies in getting a reliable detection method, since the MSI product code is meaningless due to the way Firefox’s MSI package works. At this point, you may be thinking, but that’s easy – use a file presence detection method. Tried that. It works but it means you’ll get an error message in Software Center when you uninstall Firefox. (Same result if you use registry detection.)

I worked around the issue by using a custom PowerShell detection script. For what it’s worth, the script is practically identical to my XAMPP detection method (which suffers the same “uninstalled but still detected” error in Software Center because the uninstaller launches a separate uninstallation process, causing the one launched by MECM to exit with code 0).

Here’s the code:

$version = "114.0.1"
$path = "$env:ProgramFiles\Mozilla Firefox\firefox.exe"
$uninstallProcess = "Un_A.exe"
 
$appVersion = (Get-Command $path -ErrorAction SilentlyContinue).FileVersionInfo.ProductVersion
$uninstalling = (Get-Process | Where-Object {$_.Name.StartsWith($uninstallProcess)}).Count -gt 0
if ($appVersion -ge $version -and -not $uninstalling) {
    Write-Host "Installed" # Do not change this line - this must be read by SCCM
}
else {}

The code basically searches C:\Program Files\Mozilla Firefox (for the sake of simplicity, let’s expand the environment variables to a standard configuration) for firefox.exe and checks that its version is 114.0.1 or newer. However, if there exists a process with a name starting with “Un_A.exe” (which is the Firefox uninstall process name), the product is not considered installed.

~LP

Leave a comment