PDA

View Full Version : Companion Files



Aaron Young
07-23-2002, 06:01 PM
I'd like to use the Companion Files capabilty to force my "Sample" Data to be reinstalled everytime a customer installs over an existing copy.

I know I need to set the Version of the "Non-Version" files to the KeyName of the KeyFile I want to companion them too, but what I was wondering was, if I set the version of a single file in a component to be a companion file, would that force all files in the same component to be installed/reinstalled? (I'm looking at setting the version for 600+ files otherwise :eek: )

- Aaron.

RobertDickau
07-24-2002, 09:12 AM
Sounds like a job for Automation: for example, the following VBScript touches up the File table of a built MSI database:

Set oMSI = CreateObject("WindowsInstaller.Installer")

' open DB direct read-write
Set oDB = oMSI.OpenDatabase("SampleApp.msi", 2)

' select every file version field in component
' "Sample.exe" except the key file;
' TO DO: don't hard-code key file name
Set oView = oDB.OpenView( _
"SELECT `Version` FROM `File`" & _
" WHERE `Component_`='Sample.exe' AND `File`<>'Sample.exe'")
oView.Execute

Set oRec = oView.Fetch

While Not (oRec Is Nothing)
' replace version with (ahem) key file file key
oRec.StringData(1) = "Sample.exe"
oView.Modify 4, oRec ' i.e., replace

Set oRec = oView.Fetch
Wend

' clean up
oView.Close
oDB.Commit
Set oMSI = Nothing

Aaron Young
07-24-2002, 09:34 AM
Robert,

Thanks very much, automation never even crossed my mind.

- Aaron.