views:

125

answers:

2

We develop a product which is distributed by our clients to their customers. We need to allow the administrator at the client company to make configuration changes to the installer before he sends it out to the end-user. Configuration changes in this case means a couple of registry entries to be made on the end-users computer. How do I do this?

+2  A: 

Please check this: http://ozgrant.com/2008/03/11/customising-your-wix-msi-with-transform-files/

Here,

  • Developing team creates a generic installer.
  • The IT, team then creates different Transforms (.mst files) using Orca and,
  • These installer with particular .mst is shipped to different set of clients.

HTH

nils_gate
+2  A: 

Here's a sample script that we send out to our customers. They create a custom config file, run this script, and end up with an MST and a CAB that will overwrite the default included in the base MSI.

Originally we just gave the customers instructions to use Orca, but that really only enables them to update properties/values - if you need to replace a config file then it ends up a bit complicated for most IT staff unless they have access to WISE, InstallShield or similar.

Option Explicit

Const MSI_SRC = "myapp.msi"
Const MSI_TEMP = "temp.msi"
Const MST_FILE = "custom.mst"
Const MY_CONFIG = "customsettings.reg"
Const CAB_FILE = "config.cab"

Dim filesys 
Set filesys=CreateObject("Scripting.FileSystemObject")

If filesys.FileExists(MSI_SRC) Then
   filesys.CopyFile MSI_SRC, MSI_TEMP
Else
    MsgBox "Unable to find " & MSI_SRC & "exiting", 48, "Fatal Error"
    Set filesys = Nothing
    WScript.Quit
End If

If filesys.FileExists(MST_FILE) Then
   filesys.DeleteFile(MST_FILE)
End If


Dim installer, database, database2, view

Set installer = CreateObject("WindowsInstaller.Installer")
Set database = installer.OpenDatabase (MSI_TEMP, 1)
Set database2 = installer.OpenDatabase (MSI_SRC, 1)

If filesys.FileExists(MY_CONFIG) Then
    Dim objFile, size, result, seq, objCab
    Set objCab = CreateObject("MakeCab.MakeCab.1")
    objCab.CreateCab CAB_FILE, False, False, False
    objCab.AddFile MY_CONFIG, filesys.GetFileName(MY_CONFIG)
    objCab.CloseCab

    Set objFile = filesys.GetFile(MY_CONFIG)
    size = objFile.Size

    Set view = database.OpenView ("SELECT LastSequence FROM Media WHERE DiskId = 1")
    view.Execute
    Set result = view.Fetch
    seq = result.StringData(1) + 1 ' Sequence for new configuration file

    Set view = database.OpenView ("INSERT INTO Media (DiskId, LastSequence, Cabinet) VALUES ('2', '" & seq & "', '" & CAB_FILE & "')")
    view.Execute

    Set view = database.OpenView ("UPDATE File SET FileSize = " & size & ", Sequence = " & seq & ", FileName = 'CUSTOM~2.REG|customsettings.reg' WHERE File = '" & LCase(MY_CONFIG) & "'")
    view.Execute
End If


database.GenerateTransform database2, MST_FILE
database.CreateTransformSummaryInfo database2, MST_FILE, 0, 0

' Cleanup
Set database = Nothing
Set database2 = Nothing
Set installer = Nothing
Set view = Nothing

filesys.DeleteFile(MSI_TEMP)
Set filesys = Nothing
sascha
Hi sascha: The script solution you posted is exactly what I was looking for. I got your script to run without any errors and the modified date on the msi updated. I tried modifying two different files. 1) logo2.gif when I ran the installer I got errors: "The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2755." Then, "Back from server. Return value: 110." Then i tried and ascii config file. After that, I was able to install with no errors... but the file that got installed wasn't the updated one :(
blak3r