/build/static/layout/Breadcrumb_cap_w.png

Custom Actions

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   [ + ] Show comments

Answers (1)

Posted by: pjgeutjens 12 years ago
Red Belt
0
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
Else
WScript.Exit 1
End If
End If
Next

Set oShell = Nothing
Set oReg = Nothing
end Function


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

Rgds,

PJ
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ