/build/static/layout/Breadcrumb_cap_w.png

Force msi to overwrite files

Hi, I have made a simple package that should overwrite som existing files.
exe, txt and some other files. But it does not overwrite some files, is there a way to force the msi to overwrite the files, even when a versionnumber is lower o a date is newer that the one i try to send out, i guess this is some of the problems why it doesn't overwrite the files.

any tips?

0 Comments   [ + ] Show comments

Answers (9)

Posted by: brenthunter2005 18 years ago
Fifth Degree Brown Belt
0
Look into the REINSTALLMODE property... (and the 'a' code)
Posted by: jonasm 18 years ago
Blue Belt
0
I dunno if it works, but in InstallShield 11.50 is there a setting "Always Overwrite" if you right-click a file and select properties.
I have never tried it myself.

/Jonas
Posted by: painless 18 years ago
Senior Yellow Belt
0
Thanks for the fast reply, will try your tips.
Posted by: Foleymon 18 years ago
Orange Senior Belt
0
painless-
Also check to see that those files are not in use. I have had a couple of packages that have had that problem even when told to overwrite excisting (using WISE any ver.) Have had to delete the files and then copy the new ones over and that usually takes care of it.
-m
Posted by: Lillude 18 years ago
Senior Purple Belt
0
Hi,
To replace file fourcefully try using file version in the file table for the files u want to be replaced. As per Windows Installer file-versioning rules, a versioned file will overwrite an unversioned file.

So if the files you want to replace are unversioned then give some version to them and it should replace.

Lillude
Posted by: cs_m_si 18 years ago
Senior Yellow Belt
0
Hello,

You could try to include the file in the RemoveFile table with InstallMode 1 or 3. On installation, the current file will be removed by the RemoveFiles action, which takes place before the InstallFiles action. Your file will then be installed by the InstallFiles action.

Kind regards,

CS
Posted by: kpepper 15 years ago
Yellow Belt
0
I struggled with this for a long time. The Reinstall mode seemed to force a reinstall of the entire Net 3.5 framework, and I just wanted my application files to be overwritten. I instead used a vbscript to set the file version on all files that need to install each time. Here is a vb script that can be placed in the setup project's post build event to set the version of every file with attribute "512" to the product version. "512" is a file set as vital to your application. Microsoft's sample file versioning vbscript is the base of this program. It still has a few more variables than it needs but will give you the basic idea, and it works.

' Windows Installer utility to report or update file versions, sizes, languages
' For use with Windows Scripting Host, CScript.exe or WScript.exe
' Copyright (c) Microsoft Corporation. All rights reserved. - changed by pepper
' Demonstrates the access to install engine and actions
'
Option Explicit
' FileSystemObject.CreateTextFile and FileSystemObject.OpenTextFile
Const OpenAsASCII = 0
Const OpenAsUnicode = -1
' FileSystemObject.CreateTextFile
Const OverwriteIfExist = -1
Const FailIfExist = 0
' FileSystemObject.OpenTextFile
Const OpenAsDefault = -2
Const CreateIfNotExist = -1
Const FailIfNotExist = 0
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Const msiOpenDatabaseModeReadOnly = 0
Const msiOpenDatabaseModeTransact = 1
Const msiViewModifyInsert = 1
Const msiViewModifyUpdate = 2
Const msiViewModifyAssign = 3
Const msiViewModifyReplace = 4
Const msiViewModifyDelete = 6
Const msiUILevelNone = 2
Const msiRunModeSourceShortNames = 9
Const msidbFileAttributesNoncompressed = &h00002000

Dim message1

Dim databasePath : databasePath = "H:\active\claim_master_work\wv2008\cm\ClaimMaster Installation\Release\ClaimMaster Installation.msi"

Dim newVersion : newVersion = ""
Dim console : If UCase(Mid(Wscript.FullName, Len(Wscript.Path) + 2, 1)) = "C" Then console = True
' Connect to Windows Installer object
On Error Resume Next
Dim installer : Set installer = Nothing
Set installer = Wscript.CreateObject("WindowsInstaller.Installer") : CheckError
Dim errMsg
' Open database
Dim database, openMode, view, record, updateMode, sumInfo
openMode = msiOpenDatabaseModeTransact
Set database = installer.OpenDatabase(databasePath, openMode) : CheckError
' Create an install session and execute actions in order to perform directory resolution
installer.UILevel = msiUILevelNone
Dim session : Set session = installer.OpenPackage(database,1) : If Err <> 0 Then Fail "Database: " & databasePath & ". Invalid installer
package format"


Dim stat : stat = session.DoAction("CostInitialize") : CheckError
If stat <> 1 Then Fail "CostInitialize failed, returned " & stat
' Get the product version
Dim nametofind : nametofind = "'ProductVersion'"
Dim versionview
Set versionview = database.OpenView("SELECT Value FROM Property WHERE Property = " &nametofind ) : CheckError
versionview.Execute : CheckError
Set record = versionview.Fetch : CheckError
If record Is Nothing Then
message1 = "did not find the product version"
wscript.Echo message1
Else
newVersion = record.StringData(1)
End if
' List all files in the msi package
Set view = database.OpenView("SELECT FileName,FileSize,Attributes,Language,Version,Sequence FROM File " ) : CheckError
view.Execute : CheckError

' Fetch each file and request the source path, then verify the source path, and get the file info if present
Dim fileKey, fileName, folder, sourcePath, fileSize, version, language, delim, message, info
Do
Set record = view.Fetch : CheckError
If record Is Nothing Then Exit Do
' update File table info
If record.StringData(3) = "512" Then
record.StringData(5) = newVersion
End If
view.Modify msiViewModifyUpdate, record : CheckError
Loop

' Commit database in case updates performed
database.Commit : CheckError
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 & vbNewLine & errRec.FormatText
End If
Fail message
End Sub
Sub Fail(message)
Wscript.Echo message
Wscript.Quit 2
End Sub
Posted by: cygan 15 years ago
Fifth Degree Brown Belt
0
using Companion Files can also solve your problem
Posted by: sk 15 years ago
Senior Yellow Belt
0
Indeed, companion files/parents is a good option if you have a file with a higher version. It could also be done creating a component with a dummy file (empty text for example) and set that file as keypath for the component. Then add the other files to that component. If you have files that install in different directories you have to repeat this for each directory. A simple custom action that copies the file is also a possibility.
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