cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
DelboyJay
Level 2

Disable Custom Action in an old MSI on upgrade

Hi People,

I have a question about disabling custom actions in the old msi when you are upgrading and the old MSI is uninstalled, my problem is as follows.

1) MSI 1 is installed on the machine which has been written poorly!
2) MSI 2 upgrades MSI 1 properly; this works fine and uses the "Install Setup and remove unneeded files"
3) MSI 1 when it is uninstalled by MSI 2 near the end of the upgrade, it runs a custom action that executes an EXE and I do not want this to happen. I have established that the exe is also the cached version of the exe even though the component was set to run the installed file and NOT from the binary stream (this is not confusing at all!). I thought I could add a fix in the the new exe so skip execution on an upgrade but because of this it does not work.

So basically I want to stop this custom action from running somehow when the old MSI is uninstalled. Can anyone give me some pointers please or is this just not possible?

Thanks,

Delboy
Labels (1)
0 Kudos
(5) Replies
ITI_Randy
Level 6

I had a similar situation a couple of years ago. We had a setup which was released to many customers which had a flaw preventing it from even uninstalling. Since it wouldn't uninstall, it also could not be updated with a major upgade. I was able to fix it without much impact on the customer. In similar fashion to what I did, you could do was follows:

1. Create an updated package which fixes the problem in the original troubled package, in your case, it will remove the custom action on uninstall that you don't want to run. No other changes are made, other than the one you need, and make it a minor upgrade to the original. The only thing you will want to happen here is for the package to be re-cached without the problem action. I'll refer to this as package "A".

2. Your new version you are trying to install I'll refer to as package "B". This should be a Major upgrade. To this package, add a prerequisite check which looks to see if the problem package in question was installed on the target machine. If it was installed, launch the fix package (package "A" above), passing the parameter of "REINSTALLMODE=v". This tells the Windows Installer to replace the existing (problematic) cache on the target machine.

3. The new version, a major upgrade (package "B"), will now run after the prerequisite is finished. It will preform the normal Major upgrade, removing the existing version by running from cache (your new cache, without the CA), and since the cache is now replaced, the undesirable action does not occur. It simply removes as it should and the new version replaces it.
0 Kudos
marekb
Level 2

I have similar problem like Delboy - but in my scenario the middle step is not allowed. 😮

I have to disable custom action, that is launched from old package while "RemoveExistingProducts" but I cannot do this: "Create an updated package which fixes the problem in the original troubled package, in your case, it will remove the custom action on uninstall that you don't want to run".

Is there any other way to eliminate unnecessary CA from the old package using the new version?

Thanks in advance,
Marek
0 Kudos
ITI_Randy
Level 6

Marek,

Unfortunately, if it is a major upgrade, the previous installation will be removed during the upgrade, causing the custom action to run on uninstall.

Does the new build have to be a major upgrade? Can it be a minor upgrade? A minor upgrade could be ran on the target machine with the same command-line parameter as described previously, causing it to recache without the issue in future versions.

On another note, I'm just curious, but why can't you create a prerequisite package to run as described in step 2?
0 Kudos
DelboyJay
Level 2

Thanks for the reply guys it helped me find a solution that I was happy with. I finally resorted to doing the following:

Create a VB script that locates the cached MSI of the previous installation and changes the database so that the old custom action in question is no longer executed.

... And it works perfectly, I have even created a rollback script so that it will still uninstall the old MSI properly if we choose not to upgrade half way through an upgrade.

I have added the script below for people to have a look at and modify for their puropse if required.

Thanks again for the help. 😉

Delboy

'------- begin script ------
Option Explicit
On Error Resume Next
Const msiOpenDatabaseModeTransact = 1
Dim sDisplayName, installer, sVersionMajorNumber , sProductCode, sProductName, sMyProdCode, sMsiCache
Dim sQuery, query, view, databasePath, database, openMode
openMode = msiOpenDatabaseModeTransact

Set installer = CreateObject("WindowsInstaller.Installer")

For Each sProductCode In installer.Products

'MsgBox sProductCode,64,"ProductCode"
sDisplayName = installer.productInfo(sProductCode, "ProductName")
'MsgBox sDisplayName,64,"ProductName"
sVersionMajorNumber = Installer.productInfo(sProductCode, "VersionMajor")

If sVersionMajorNumber = 4 And (sDisplayName = "MyProduct") Then
sMsiCache = installer.productInfo(sProductCode, "LocalPackage")
'MsgBox sVersionNumber ,64,"Version"
'MsgBox sMsiCache,64,"MsiCacheName"
Exit For
End If

Next

' Modify condition of the 'U10_UnregService' to stop it running
databasePath = sMsiCache
sQuery = "UPDATE InstallExecuteSequence SET Condition='0' WHERE Action='U10_UnregService'"
Set database = installer.OpenDatabase(databasePath, openMode)
Set view = database.OpenView(sQuery)
view.Execute
database.Commit
wscript.quit

'------- end script --------
0 Kudos
marekb
Level 2

Delboy,

Great job!

The line:
sMsiCache = installer.productInfo(sProductCode, "LocalPackage")
is that what I need, and works perfect...:)

With kindest regards,
Marek
0 Kudos