Below is a script that will automatically uninstall and reinstall a 32bit application.
Please note: This script only works with 32bit applications!
In order for this script to work, you will need to configure the following:
$Appname = Insert Application Name
$AppSetup = Insert Application File Path After MSIEXEC /I
$Silent = Insert Silent Install Switches
$SilentUninstall = Insert Silent Uninstall Switches
I am using TightVNC for the following example:
$appname = 'TightVNC' $32bit = get-itemproperty 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*' | Select-Object DisplayName, DisplayVersion, UninstallString, PSChildName | Where-Object { $_.DisplayName -match "^*$appname*"} $appSetup="msiexec /i tightvnc-2.7.10-setup-64bit.msi" $silent = " /quiet /norestart ADDLOCAL=Viewer" $silentuninstall = " /qn" if ($32bit -eq "" -or $32bit.count -eq 0) { Write-Host "Software is not Installed" Start-Sleep -s 3 Clear-Host Write-Host "Starting Setup..." cmd /c ($appSetup + $silent) Clear-Host Write-Host "Installation Complete!" Start-Sleep -s 3 } else { $Uninstallstring = $32bit.UninstallString -replace 'msiexec.exe /i','msiexec.exe /x' Write-Host "Uninstalling Software..." cmd /c ($uninstallstring + $silentuninstall) Clear-Host Write-Host "Starting Setup..." cmd /c ($appSetup + $silent) Clear-Host Write-Host "Installation Complete!" Start-Sleep -s 3 }
Enjoy!