cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
obrion
Level 3

How to populate the UpgradedFilesToIgnore Table?

I have a project which I have designed a patch for using the InstallShield 2008 Installation Designer. Some of the files in the project are regularly updated once our product is installed, so when I install a patch I do not want to upgrade these particular files, as it is likely the files on the end user's workstation will already be newer than the files in the patch. How can I use InstallShield to populate the UpgradedFilesToIgnore table so that these files are not included in my patch?

Bob O'Brion
AT&T
Labels (1)
0 Kudos
(5) Replies
sks2004
Level 4

You can add to the UpgradedFilesToIgnore table using Orca... opening/editing the PatchTemplate.pcp that Macrovision uses, which I think exists within the "...Support" directory (I'm not near an InstallShield IDE computer right now to verify).

I write/alter the pcp as part of our build process, via msi COM interface. I'll provide a vbs sample if requested.
0 Kudos
obrion
Level 3

An example would be excellent! I am using a vbscript to build our installer and the patches as well. At the moment I just use the BuildPatchConfiguration() method of the project object in InstallShield automation interface to build the existing patches I have defined using the IDE. Alter the sample pcp file would be okay, but if you have an example of how to update the configuration with a script that would be ideal.

Thanks!

Bob
0 Kudos
obrion
Level 3

Just thought I would follow up with another post in hopes some example code could be provided to programmatically alter the pcp file so I could exclude some files from a patch.

Thanks again!

Bob
0 Kudos
RobertDickau
Flexera Alumni

It doesn't address that issue directly, but perhaps visit the Resources > Tips & Tricks section of the InstallShield page http://www.macrovision.com/products/installation/installshield.htm; the "Using MSI Automation to Modify a Developer 7 Project" tip (PDF warning) talks about modifying an MSI-format file (MSI, ISM, PCP), and the "Accessing the MSI Database at Run Time" tip talks more about MSI SQL queries...
0 Kudos
sks2004
Level 4

I wrote this 2 years ago, borrowing a few ideas from a sample Microsoft script, and have been using it with success... we deliver alot of patches.

Have your build process call this VBScript, don't forget to supply the necessary parameters (not all are required).

I removed some product/company specific items... and haven't recompiled, so you may need to adjust a line or two.


Option Explicit

Const msiOpenDatabaseModeReadOnly = 0
Const msiOpenDatabaseModeTransact = 1
Const PATCH_GUID_LIST = "C:\Patch\PatchGUIDlist.log"
Const APPNAME_UPGRADEIMAGES_KEY = "Latest"

Dim sPathToMsi
Dim sIgnoreProcess()' The number of SQL statements to pass...into the Ignore
Dim sWholeProcess()'
Dim sAlwaysSQL(8)
Dim X
Dim objArgs
Dim argCount
Dim ArgNum
Dim Y: Y = 0
Dim sUpgradeMsi
Dim sTargetMsi
Dim sWholeFiles
Dim sPatchGUID
Dim pProject
Dim sBuildVersion
Dim sServiceRelease
Dim sProductName
Dim sWholeFilesList
Dim sIgnoreFilesList
Dim saWholeFiles
Dim saIgnoreFiles
Dim bWholeExists
Dim bIgnoreFilesExists
Dim sWholeFile
Dim sFileToIgnore
Dim sFileKeyValue
Dim sPathToPvkFile
Dim sDigitalSignaturePwd
Dim sPathToSpcFile


'-PATHTOMSI = The fully qualified path to the PatchTemplate.pcp file
'-PATHTOLATEST = Fully qualified path to the LATEST build's MSI file
'-PATHTOPREVIOUS = Fully qualified path to the PREVIOUS build's MSI file
'-BUILDVERSION = Include Whole files (1 = YES 0 = NO)
'-BUILDVERSION = BuildVersion
'-SRVALUE = Service Release Value ("Service Release 1")
'-PRODUCTNAME = ProductName property value
'-WHOLEFILES = FIle to include as whole
'-IGNOREFILES = File Key name of the file to NOT PATCH
'-PATHTO_PVK_FILE = Path to the PVK digital signature
'-DIGITALSIGNATUREPWD = Digital Signature password
'-PATHTO_SPC_FILE = Path to the digital signature SPC file

'Sample commandline:
'WiRunSQL_IgnoreFIles.vbs -PathToMsi "C:\Patch\PatchTemplate.pcp" -PathToLatest "E:\Releases\2007\AppName\current\DateTimeStamp\Release\DiskImages\Disk1\Software.msi" -PathToPrevious "E:\Releases\2007\AppName\old\DateTimeStamp\Release\DiskImages\Disk1\Software.msi" -BuildVersion "Build Version 13" -SrValue "Service Release 12" -ProductName "My ProductName" -WholeFiles "filekey1.exe:filekey2.exe" -IgnoreFiles "filekey8.exe:filekey9.exe" -PATHTO_PVK_FILE "C:\Wherever\Wherever.pvk" -DIGITALSIGNATUREPWD "password" -PATHTO_SPC_FILE "C:\DontKnow\DontKnow.SPC"

'***************************************************************
'This is called only to generate a GUID...
set pProject = CreateObject("SAAuto14.ISWiProject")
sPatchGUID = pProject.GenerateGUID
Set pProject = nothing
'***************************************************************

Set objArgs = WScript.Arguments
argCount = Wscript.Arguments.Count

For X = 0 To (argCount - 1)
Select Case UCase(objArgs(X))
Case "-PATHTOMSI"
sPathToMsi = objArgs(X + 1)
Case "-PATHTOLATEST"
sUpgradeMsi = objArgs(X + 1)
Case "-PATHTOPREVIOUS"
sTargetMsi = objArgs(X + 1)
Case "-BUILDVERSION"
sBuildVersion = objArgs(X + 1)
Case "-SRVALUE"
sServiceRelease = objArgs(X + 1)
Case "-PRODUCTNAME"
sProductName = objArgs(X + 1)
Case "-WHOLEFILES"
sWholeFilesList = objArgs(X + 1)
Case "-IGNOREFILES"
sIgnoreFilesList = objArgs(X + 1)
Case "-PATHTO_PVK_FILE"
sPathToPvkFile = objArgs(X + 1)
Case "-DIGITALSIGNATUREPWD"
sDigitalSignaturePwd = objArgs(X + 1)
Case "-PATHTO_SPC_FILE"
sPathToSpcFile = objArgs(X + 1)
End Select
Next


'sWholeFilesList = a colon delim collection of file keys to include as whole "filekey1:filekey2:filekey3"
'sIgnoreFilesList = a colon delim collection of file keys to ignore for patching

'Disect the colon-delim string, putting into single dimension arrays
If not(sWholeFilesList = "") Then

saWholeFiles = Split(sWholeFilesList, ":")

If Not(saWholeFiles(0) = "") then
bWholeExists = True
Else
bWholeExists = False
End If

End If

If not(sIgnoreFilesList = "") Then
saIgnoreFiles = Split(sIgnoreFilesList, ":", -1, 1)

If not(saIgnoreFiles(0) = "") then
bIgnoreFilesExists = True
Else
bIgnoreFilesExists = False
End If

End If


If (sServiceRelease = "") Then sServiceRelease = "Service Release"

sAlwaysSQL(0) = "UPDATE `UpgradedImages` SET `UpgradedImages`.`MsiPath` = '" & sUpgradeMsi & "' WHERE `UpgradedImages`.`Upgraded` = 'Latest'"
sAlwaysSQL(1) = "UPDATE `TargetImages` SET `TargetImages`.`MsiPath` = '" & sTargetMsi & "' WHERE `TargetImages`.`Target` = 'Previous'"
sAlwaysSQL(2) = "UPDATE `Properties` SET `Properties`.`Value` = '" & sWholeFiles & "' WHERE `Properties`.`Name` = 'IncludeWholeFilesOnly'"
sAlwaysSQL(3) = "UPDATE `Properties` SET `Properties`.`Value` = '" & sPatchGUID & "' WHERE `Properties`.`Name` = 'PatchGUID'"
sAlwaysSQL(4) = "UPDATE `PatchMetadata` SET `PatchMetadata`.`Value` = '" & sServiceRelease & "' WHERE `PatchMetadata`.`Property` = 'DisplayName'"
sAlwaysSQL(5) = "UPDATE `Properties` SET `Properties`.`Value` = '" & sProductName & "' WHERE `Properties`.`Name` = 'ProductName'"

sAlwaysSQL(6) = "UPDATE `Properties` SET `Properties`.`Value` = '" & sPathToPvkFile & "' WHERE `Properties`.`Name` = 'SignatureCPK'"
sAlwaysSQL(7) = "UPDATE `Properties` SET `Properties`.`Value` = '" & sDigitalSignaturePwd & "' WHERE `Properties`.`Name` = 'SignaturePassword'"
sAlwaysSQL(8) = "UPDATE `Properties` SET `Properties`.`Value` = '" & sPathToSpcFile & "' WHERE `Properties`.`Name` = 'SignatureSPC'"

If (bIgnoreFilesExists = True) then
ReDim sIgnoreProcess(UBound(saIgnoreFiles))

Y = 0
For Each sFileToIgnore In saIgnoreFiles
sIgnoreProcess(Y) = "INSERT INTO `UpgradedFilesToIgnore` (`UpgradedFilesToIgnore`.`Upgraded`, `UpgradedFilesToIgnore`.`FTK`) VALUES ('*', '" & sFileToIgnore & "')"
Y = Y + 1
Next
End If


If (bWholeExists = True) then
ReDim sWholeProcess(UBound(saWholeFiles))

Y = 0
For Each sWholeFile In saWholeFiles
sWholeProcess(Y) = "INSERT INTO `UpgradedFiles_OptionalData` (`UpgradedFiles_OptionalData`.`Upgraded`, `UpgradedFiles_OptionalData`.`FTK`, `UpgradedFiles_OptionalData`.`IncludeWholeFile`) VALUES ('" & APPNAME_UPGRADEIMAGES_KEY & "', '" & sWholeFile & "', '1')"
Y = Y + 1
Next
End If


Dim openMode : openMode = msiOpenDatabaseModeTransact

' Connect to Windows installer object
On Error Resume Next
Dim installer : Set installer = Nothing
Set installer = Wscript.CreateObject("WindowsInstaller.Installer") : CheckError

' Open database
Dim databasePath:databasePath = sPathToMsi
Dim database : Set database = installer.OpenDatabase(databasePath, openMode) : CheckError

' Process SQL statements
Dim query, view, record, message, rowData, columnCount, delim, column


If (bIgnoreFilesExists = True) then
'query = "DELETE FROM `UpgradedFilesToIgnore`"
'Set view = database.OpenView(query) : CheckError
'view.Execute : CheckError

For Each query In sIgnoreProcess
Set view = database.OpenView(query) : CheckError
view.Execute : CheckError
Next
End If

If (bWholeExists = True) then
query = "DELETE FROM `UpgradedFiles_OptionalData`"
Set view = database.OpenView(query) : CheckError
view.Execute : CheckError

For Each query In sWholeProcess
Set view = database.OpenView(query) : CheckError
view.Execute : CheckError
Next
End If

For Each query In sAlwaysSQL
Set view = database.OpenView(query) : CheckError
view.Execute : CheckError
Next


If openMode = msiOpenDatabaseModeTransact Then database.Commit
If Not IsEmpty(message) Then
Wscript.Echo message
Else
Wscript.Echo "The Installer database has been updated successfully"

'Write the PatchGUIDs...to the LogFile
WriteVersionFile PATCH_GUID_LIST, (sPatchGUID & vbTab & sBuildVersion)

End If


Wscript.Quit 0


Sub CheckError
Dim message, errRec
If Err = 0 Then Exit Sub
message = Err.Source & " " & Hex(Err) & ": " & Err.Description
If Not installer Is Nothing Then
Set errRec = installer.LastErrorRecord
If Not errRec Is Nothing Then message = message & vbLf & errRec.FormatText
End If
Fail message
End Sub

Sub Fail(message)
Wscript.Echo message
Wscript.Echo sFileKeyValue
Wscript.Quit 2
End Sub

Function WriteVersionFile(FilePath, VersionValue)

Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso
Dim f

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(FilePath, ForAppending, True)

f.Write VersionValue
f.WriteBlankLines(1)
End Function
0 Kudos