Archive: Uninstall Old MSI Via Upgrade Code


Uninstall Old MSI Via Upgrade Code
Hi all,

I must say that I am completely confused as to how I could uninstall my previous versions of an application that were made with MSI (InstallShield Express) via a known Upgrade Code. As the product code has changed for each build, I cannot just reference an msiexec /x{product code} for each one, and I don't believe I even have historical data on each product code.

The one common part of the MSI's I had created via InstallShield was the Upgrade Code. InstallShield has an easy setup to remove previous versions based upon the Upgrade Code, but I see no reference anywhere on how this may be done using NSIS. I have literally spent hours Googling, reading the manuals, etc, and only have come to bother everyone in hopes that there is in fact a way to make this happen. Thanks for any help.

Derek


first off, I don't know anything about MSI...

but just checking the registry, you can look up upgrade codes in
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\UpgradeCodes
and HKEY_CURRENT_USER\Software\Microsoft\Installer\UpgradeCodes

in there you will find a number (not sure if thats the product code), but in the same parent key as UpgradeCodes, there is a subkey named Products with a subkey for that number, in there you will find a value named PackageCode (I'm assuming one of these GUIDs is a product id that you can use) If not, you will have to check msdn to find out how to find the product code

Edit: looking in the registry is probably not the best way to go about this, you could call MSI api with the system plugin, starting with MsiEnumProducts() or something like that

Edit2: It turns out, those GUID's in the registry are "encoded", see http://nsis.sourceforge.net/Blocking_older_MSI_setups Just do a search for MSI on the wiki, several pages with lots of info

Edit3: MsiEnumRelatedProducts is probably what you want, or if you know the component id; MsiGetProductCode



!define upgradecode {65E6DE48-A358-434D-AA4F-4AF72DB4718F} ;Python upgrade code used here

StrCpy $0 0
loop:
System::Call 'MSI::MsiEnumRelatedProducts(t "${upgradecode}",i0,i r0,t.r1)i.r2'
${If} $2 = 0
DetailPrint product:$1
IntOp $0 $0 + 1
goto loop
${Endif}

Wow - those two replies were quick and right on the money. Thank you so much for the assistance, this saved my evening!