VBScript To Remove Current Software Installs

Sometimes when we’re deploying software in our SCCM environment, we run across a niche application that requires previous versions to be manually uninstalled before the new one can be installed. Sometimes this can encompass several different versions of the application, or even several different removal codes. Typically the uninstall strings are tracked down and utilized to remove software, well, what if you’re not sure of all the various uninstall codes? Hence, a VBScript to help handle the painful task.

VBScript IconRemoveCurrentInstalls.vbs (right-click and save the linked file)
(you will need to save the file and then change the .TXT extension to .VBS)

There are a few things you need to know about the script:

  • It is currently coded to work on both 32-bit and 64-bit operating systems.
  • It is currently geared to search through the DisplayNames within the HKLM registry.
  • If you use a special character in the search string, use "\" before the special character.
  • The search string is not case sensitive, and it does not have to be the entire DisplayName – but since the script only compares patterns, make sure you include enough info so that other applications are not accidentally uninstalled.
  • You only need to edit Lines 33-36, supplying the settings for the application to remove.
  • When used with SCCM, it is suggested that you remove the comment from the beginning of Line 22 so that if any errors occur, it quietly continues.
  • The script has limited error checking in order to help make it readable to novices

NOTE 1: If you use Notepad to edit a VBScript, make sure you disable Word Wrap (Format | Word Wrap) as it makes things easier to read.

NOTE 2: If using Notepad, once you disable Word Wrap you can display line numbers by selecting the View | Status Bar menu item. The line number that the cursor is on will now display in the lower right corner of the window.

EXAMPLES (Lines 33-36)
To uninstall a 32-bit application (in this case, QuickTime):
SetApplicationPathItems "32-bit"
RemoveCurrentInstalls "QuickTime"

To uninstall a 64-bit application (in this case, iTunes):
SetApplicationPathItems "64-bit"
RemoveCurrentInstalls "iTunes"

To uninstall both a 32-bit and a 64-bit version of the application (in this case, JAVA):
SetApplicationPathItems "32-bit"
RemoveCurrentInstalls "Java 2 Runtime Environment"
RemoveCurrentInstalls "J2SE Runtime Environment 5.0"
RemoveCurrentInstalls "Java\(TM\) 6 Update"
SetApplicationPathItems "64-bit"
RemoveCurrentInstalls "Java\(TM\) 6 Update"

email

Written by , Posted .
  • Stevo

    Great post! Not sure why no one has commented…..Anyway, worked for me! Good for those bricked installs. And with GPO even better. THX!

  • Nathaniel Beven

    Using this with a install.cmd in SCCM and it works perfectly. Great for removing old java versions before pushing out the latest version. Thank you!