I have a little dilemna here...

Someone packaged an application and thought it would be ok to include a vbscript custom action (Execute from installed files) under Execute Immediate. This script grants directory and file permissions. The problem is that the script is not conditioned therefore when you uninstall guess what happens. The file is uninstalled before the custom action executes. When the custom action kicks in we're faced with an error then it bails immediately after.

We can supress the error with a /qn switch but this does not solve the issue. I need this to uninstall with no errors.

Other than creating a new package and deploying this package with the same package code using "REINSTALL=ALL REINSTALLMODE=VAMUS" without the custom action then uninstalling, is there another way?
0 Comments   [ - ] Hide Comments


Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
Answer this question or Comment on this question for clarity


There is another way but it's not exactly simple...

First of all you create a package with the necessary fix, in your case a condition on the setsecurity CA like Not Remove ~='ALL'
You then copy this fixed version to the target machines or another place accessible by the machines.

The next part is the hard part, it involves 'overwriting' Windows Installer registry data so the installation indicates your new MSI as its source. For this you need to go look in 2 places

1) HKLM\Software\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\products\<GUID Hash>\LocalPackage
First of all you need to find the correct set of keys (the GUID hash). You can do this by reading the DisplayName key, this matches your ProductName
then you need to overwrite the LocalPackage value with the path to your new MSI. Also note this assumes the package was installed by LocalSystem (S-1-5-18)

2) HKCR\Installer\Products\<GUID Hash>\SourceList\
Here you must change the PackageName value to your MSI's filename, and the LastUsedSource value to the correct path where it can be found.

Like I said, not exactly simple, but there IS another way without reinstalling the package...Uninstalling the application will now use your new MSI instead of the old one.

I found the script below in the archives here, so I'll provide it AS IS to give you some inspiration. It'll do the job probably but it's not exactly robust, so if your PC explodes, don't blame me ;)

Function FixBadUninstall (sApplicationName)
'on error resume next
Dim oReg
Dim oShell
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
Set oShell = CreateObject("wscript.shell")
Set oFso = CreateObject("Scripting.FileSystemObject")
sKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products"
oReg.EnumKey HKEY_LOCAL_MACHINE, sKeyPath, arrSubKeys
For Each subkey In arrSubKeys
oReg.GetStringValue HKEY_LOCAL_MACHINE,sKeyPath & "\" & subkey & "\InstallProperties","DisplayName",sDisplayNameValue

If ucase(sApplicationName) = UCase (left(sDisplayNameValue,len(ucase(sApplicationName)))) Then
oReg.GetStringValue HKEY_CLASSES_ROOT,"Installer\Products\" & SubKey & "\SourceList","PackageName",sMsiName
If oFso.FileExists (getCurrentDir & "Source\SERVIPOST_CLEANUP\FixMSI\" & sMsiName) then 'Returns Current directory sMsiName
sWinInstallerMSIPath = GetRegStringValue (HKEY_LOCAL_MACHINE, sKeyPath & "\" & subkey & "\InstallProperties" , "LocalPackage")
OFso.DeleteFile (sWinInstallerMSIPath)
oReg.SetStringValue HKEY_LOCAL_MACHINE, sKeyPath & "\" & subkey & "\InstallProperties","LocalPackage", "C:\Temp\FixMSI\" & sMsiName
WScript.Exit 1
End If
End If

Set oShell = Nothing
Set oReg = Nothing
end Function

replace C:\Temp\FixMSI\ with your path.


Answered 08/04/2011 by: pjgeutjens
Red Belt

Please log in to comment