Remove-MSIApplications Bug?

Hello. I may have recently stumbled upon a bug in the Remove-MSIApplications function. I’m trying to uninstall previous versions of QGIS before installing the new version. Some versions have an .exe uninstaller, newer versions use an MSI. Here is the code I’m using to detect installed versions:

$installed = Get-InstalledApplication -Wildcard -Name "QGIS*"
		foreach($qgis in $installed)
		{
			if ($qgis.UninstallString -like "msiexec*")
			{
				Remove-MSIApplications -Name "$($qgis.DisplayName)"
				Remove-Folder -Path "$envProgramFiles\$appName $($qgis.DisplayVersion)"				
			}

When this executes, the previous version is detected, but the toolkit does not remove it (see log file below)

I’m not sure if it’s because there are single quotes in the application name, or if this is a bug in the code. I wanted to get others’ thought before filing a bug on the GitHub project. Any thoughts would be greatly appreciated!

I too believe it’s the single quotes in the $qgis.DisplayName that is making it not found by Remove-MSIApplications.

Since Get-InstalledApplication did all the detection work already, why not just use the MSI’s ProductCode instead of using Remove-MSIApplications like this:

Execute-MSI -Action Uninstall -Path "$($qgis.ProductCode)"

Remove-MSIApplications already does a match on the name so I believe you should be able to use Remove-MSIApplications -Name “QGIS” to have it remove all previous msi based versions.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.