As per the title, does this function check for incorrect MSI parameters and modify them?
I’ve encountered some apps that have UNinstall strings that calls “msiexec /I” instead of “msiexec /X”
I am currently using this piece of code but would rather remove it if it’s already being done (albeit with better code):
## <Perform Pre-Installation tasks here>
$partialAppName = "*$($adtSession.AppName)*"
$regPaths = @("HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall","HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall")
foreach ($regPath in $regPaths) {
# Get all subkeys (applications) from the registry path
$keys = Get-ChildItem -Path $regPath
foreach ($key in $keys) {
# Get the display name and uninstall string
$displayName = (Get-ItemProperty -Path $key.PSPath -Name "DisplayName" -ErrorAction SilentlyContinue).DisplayName
$uninstallString = (Get-ItemProperty -Path $key.PSPath -Name "UninstallString" -ErrorAction SilentlyContinue).UninstallString
# Check for partial match
if (($displayName -like $partialAppName) -and ($uninstallString -ne $null)) {
if ($uninstallString.StartsWith("msiexec.exe /i",'CurrentCultureIgnoreCase') ) {
$msiProductCode = $uninstallString -replace "msiexec.exe /i"
Start-ADTMsiProcess -Action 'Uninstall' -FilePath "$($msiProductCode)"
} else {
$uninstallString = $uninstallString -replace '"'
Start-ADTProcess -FilePath "$($uninstallString)" -ArgumentList '/S'
}
}
}
}