How to add ALL Uninstall Strings to Custom Inventory

Version 2
    Share This:

    Over the years I have had customers ask if BMC Client Management can automatically Uninstall Software by simply clicking on a link in Software Inventory and select Uninstall. This feature does not exist nor do I expect this will ever be enabled.  The next question is typically how can I then easily uninstall the software on the end point.  Again, not an easy question to answer. As all software titles have a unique uninstall string but BCM has an Op Rule to uninstall software that was installed using Microsoft's MSI method.  This rule requires either the Product ID number or the EXACT name as found under "Programs and Features".  This process works extremely well however there are times where this is not silent.


    We are all aware of the registry hives where these uninstall strings are located but it still takes time to get on that device to locate the exact uninstall string (for those instances where very few if not just a single device may have this particular software/version resides). That being said, I have created 4 batch files that will collect ALL of the uninstall strings from Assigned Devices (that run this Op Rule). Each batch file will retrieve the strings for 32 and 64 software packages and the Quiet Uninstall string from both locations (yes, there are keys labeled Quiet Uninstall).


    Here is an example of one Batch File:

    CMD to fetch all 32 bit Uninstall Strings

    @echo off

    set x86GUID=HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall
    for /f "tokens=2*" %%A in (
      'reg query "%x86GUID%" /V /F DisplayName /S /E 2^>nul ^| findstr "DisplayName"'
    ) do (
      for /f "delims=" %%P in ('reg query "%x86GUID%" /s /f "%%B" 2^>nul ^| findstr "HKEY_LOCAL_MACHINE"') do (
        for /f "tokens=2*" %%X in (
          'reg query "%%P" /v "UninstallString" 2^>nul ^|findstr "UninstallString"'
        ) do (
          rem echo %%Y %%B
           set MsiStr=!MsiStr:/I=/X!
    set MsiStr=%%Y     
          echo !MsiStr! %%B


    I used the Deployment Module to put these 4 batch files in a folder on the root of C:\ called BCM/Uninstall. I then run each batch file separately using the PIPE results to file function and append the file for each batch file so I end up with a single file for all results. After these batch files run I then parse the output file using the File Analysis via Regular Expression Op Rule Step and then Upload Custom Inventory.


    The results look like this:


    Custom Inventory Results (click on image to enlarge)


    Please remember that this rule must be run on a device when needed.  This means this rule collects data as a snapshot in time and changes occur all the time.  You could set the schedule for "At Startup" so after every reboot this inventory will be updated or just run "on demand" on a device where you find software you wish to uninstall.


    Here are all the steps I used. Note that I create directory in step 1 and then I delete Directory in step 2.  Step two deletes the old file that was created in the Uninstall folder that I used to add my batch files. When I created the package I added the containing folder of "Uninstall".

    I removed Step 3 (Install Package).  Once you have created the package from the attached zip file then you will need to add the new package to the Op Rule (also attached).  Simply open the Packages tab on the Op Rule and add the newly created package and then go back to the steps tab and refresh page. The install package step is at the bottom.  Move to Step 3.  You can then assign to a test device (If you still have Windows 7 devices (32 bit only) this rule will still work as I have used the Workflows to continue on error (Reg keys don't exist on 32 bit OS).


    I am attaching the Op Rule that does all the heavy lifting along with the 4 batch files.  You will need to Create the package and modify the Op Rule to include YOUR new package.


    Once you IMPORT the XML go to Lost and Found under Global Settings and COPY the new Op Rule and then paste into the Operational Rules Module.


    If you use this rule, please LIKE this post. If you have questions feel free to add comments or questions.



    Steven R. Gibbs

    Sr. Systems Consultant

    RightStar Systems
    1951 Kidwell Drive, Suite 110
    Vienna, VA