PDA

View Full Version : Edit Installed Product



DMason
04-02-2007, 01:58 PM
Can the Windows Installer object model be used to modify a currently installed product? For instance, I need to change the value of several public properties. I've hacked out a little bit of VbScript code that looks something like this:

Dim oInstaller
Dim oSession
Dim oDB
Dim oView
Dim oRecord

Set oInstaller = CreateObject("WindowsInstaller.Installer")
Set oSession = oInstaller.OpenProduct("{EA59C14D-8C3E-4462-85F8-F1F14019BFF8}") 'Product Code of installed product.
Set oDB = oSession.Database
Set oView = oDB.OpenView("SELECT * FROM Property")
oView.Execute()

Do

Set oRecord = oView.Fetch()
If oRecord Is Nothing Then Exit Do
If UCase(oRecord.StringData(1)) = "IS_SQLSERVER_DATABASE" Then

oRecord.StringData(1) = "NewDbName"
oView.Modify 4, oRecord
End If
Loop

oDB.Commit

Set oRecord = Nothing
Set oView = Nothing
Set oDB = Nothing
Set oSession = Nothing
Set oInstaller = Nothing

RobertDickau
04-04-2007, 10:46 AM
I don't have any firsthand experience with OpenProduct/MsiOpenProduct, but since it's listed in the MSI help as a "product query function", I'm not too optimistic.

In principle, you could locate the cached MSI package using ProductInfo/MsiGetProductInfo and the local-package flag, then use the MSI database functions to modify the contents of that database. However, the MSI help states that "The cached package is for internal use only", so this looks like a dangerous road to travel.

Better, probably, is to re-cache the MSI database with a small update or minor upgrade, using a REINSTALLMODE value that includes the letter "v"; or during the initial installation to cache special values you need (in the registry, for example), and then to read them back during maintenance mode.

andyamstrad
08-07-2007, 11:30 AM
I need to do something like this also. Have an installed product on the clients machine, but need to add extra components e.g. A.exe and B.exe, a list of all components like these are held in a custom table, so I would effectively add these components to the custom table along with the physical files.

One idea is to use transforms? You think modifying the cached database is doable but dangerous??