21 February 2018

Uninstall MSI by Application Name

Here is a function that will uninstall an MSI installed application by the name of the app. You do not need to input the entire name either. For instance, say you are uninstalling all previous versions of Adobe Reader. Adobe Reader is always labeled Adobe Reader X, Adobe Reader XI, and so forth. This script allows you to do this without having to find out every version that is installed throughout a network and then enter an uninstaller line for each version. You just need to enter Adobe Reader as the application name and the desired switches. It will then search the name fields in the 32 and 64 bit uninstall registry keys to find the associated GUID. Finally, it will execute an msiexec.exe /x {GUID} to uninstall that version.

Update: 

This is the third revision of the function that will uninstall an MSI by its application name. The last revision was an efficiency improvement. This revision adds the ability to uninstall all instances of an application. For instance, if several versions of Java 8 are installed, this function can uninstall all of them by just defining Java 8. The function covers both x86 and x64 based apps. The previous versions of this function could only uninstall one app at a time. This will uninstall all of them.

Here is a visual on the script uninstalling multiple versions of Java 8.


You can download the code from my GitHub site located here.

Related Posts:

  • Autodesk 2014 Building Design Suite Ultimate Uninstaller The Autodesk suite is not the easiest to uninstall because of all the components that the built in uninstaller does not uninstall. I went in and extracted all of the GUIDs for each components and created the powershell scr… Read More
  • Adding a User to the Local Administrators Group with Verification This script will add a user to the local administrators group. It will also verify if the user is added and write both a registry key for the add/remove programs and a key for the WMI entry so that it will appear in a WMI q… Read More
  • Get the Software GUID This script will get the proper software name and associated GUID. I use this script when writing uninstaller powershell scripts. You can use the GUID in an msiexec so that you do not need the source files for the uninstall… Read More
  • Disable Windows Media Center If you are needing to disable Windows Media Center in Windows 7 by command line, here is a script that will do just that. This script will not only disable it, but it will also add an add/remove programs and HKCR entry so t… Read More
  • Autodesk 2014 Uninstaller Here is a script that will uninstall Autodesk 2014. This will uninstall BDS Ultimate, which should cover all Revit 2014 applications. This also uninstalls Civil 3D 2014, but does not cover anything else from the IDSP suite.… Read More

2 comments:

  1. Nice! Here is a version that will work with Windows 10 and PackageManagement to uninstall msi, powershellget, or exe programs in a similar manner:

    Function Remove-InstalledApp ([string]$AppName) {
    get-package $AppName -ErrorAction:SilentlyContinue | Foreach {
    $app = $_
    switch ($app.ProviderName) {
    'msi' {
    Write-Output "Uninstalling msi for $($app.Name)"
    $app | Uninstall-Package
    }
    'PowerShellGet' {
    Write-Output "Uninstalling PowerShellGet package for $($app.Name)"
    $app | Uninstall-Package
    }
    'Programs' {
    if ( $null -ne $app.metadata['UninstallString'] ) {
    Write-Output "Found uninstall string for $($app.Name), calling it now..."
    Invoke-Expression "& $($app.metadata['UninstallString'])"
    }
    }
    Default {
    Write-Output "Uncertain what we should do with package $($app.Name) (Provider = $($app.ProviderName))"
    }
    }
    }
    }

    ReplyDelete
  2. wmic product where (name like'java%%') call uninstall

    ReplyDelete