Simplest solution to replace a tiny file inside an MSI?

application packaging blogs
application packaging tools
download master packager
msi repackager
msi packaging tools
msi packager
repackaging software
msi generator

Many of our customers have access to InstallShield, WISE or AdminStudio. These aren't a problem. I'm hoping there is some way I can provide our smaller customers without access to commercial repackaging tools a freely available set of tools and steps to do the file replacement themselves.

Only need to replace a single configuration file inside a compressed MSI, the target user can be assumed to already have Orca installed, know how to use this to customize the Property table (to embed license details for GPO deployment) and have generated an MST file.

Disclaimer: this is very similar to another question but both questions and answers in that thread are not clear.

Okay, revisiting this question with my own answer providing nice little VB script that will do all heavy lifting. As mentioned in the original question, the aim was provide a simple solution for sysadmin users to make the updates/changes themselves.

Below is a simplified version of the code I'm currently providing to customers

Option Explicit

Const MY_CONFIG = "MyConfigApp.xml"
Const CAB_FILE = "config.cab"
Const MSI = "MyApp.msi"

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

If filesys.FileExists("temp.tmp") Then filesys.DeleteFile("temp.tmp")
filesys.CopyFile MSI, "temp.tmp"

Dim installer, database, database2, view
Set installer = CreateObject("WindowsInstaller.Installer")
Set database = installer.OpenDatabase ("temp.tmp", 1)
Set database2 = installer.OpenDatabase (MSI, 1)

If Not filesys.FileExists(MY_CONFIG) Then WScript.Quit 2 ' No config file, abort!

Dim objFile, size, result, seq, objCab

' MakeCab object has been depreciated so we fallback to makecab.exe for with Windows 7
On Error Resume Next ' Disable error handling, for a moment
Set objCab = CreateObject("MakeCab.MakeCab.1") 
On Error Goto 0  ' Turn error handling back on

If IsObject(objCab) Then ' Object creation successful - use XP method   
    objCab.CreateCab CAB_FILE, False, False, False
    objCab.AddFile MY_CONFIG, filesys.GetFileName(MY_CONFIG)
    objCab.CloseCab
    Set objCab = Nothing
Else ' object creation failed - try Windows 7 method
    Dim WshShell, oExec
    Set WshShell = CreateObject("WScript.Shell")
    Set oExec = WshShell.Exec("makecab " & filesys.GetFileName(MY_CONFIG) & " " & CAB_FILE)
End If

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 = 'MYC~2.CNF|MyConfigApp.xml' WHERE File = '" & MY_CONFIG & "'")
view.Execute

database.GenerateTransform database2, "CustomConfig.mst"
database.CreateTransformSummaryInfo database2, "CustomConfig.mst", 0, 0
filesys.DeleteFile("temp.tmp")

Set view = nothing
Set installer = nothing
Set database = nothing
Set database2 = nothing
Set filesys = Nothing
WScript.Quit 0

Update: The MakeCab.MakeCab.1 object has been depreciated, code updated to now work with Windows 7.

Software Deployment : Replacing a file in an MSI, I have an MSI admin install and I need to replace an file in it with a newer version. Answer this question Comment on this question You might even get away with a Small Upgrade in this case (only change Package Code). Create a MST, that is verry simple and the best way to create no errors or  Simplest solution to replace a tiny file inside an MSI? (8) I asume that you create the msi file yourself (?) When you use Wix to generate your msi, the customer can simply regenerate the whole msi after replacing the file (wix is free). Otherwise it should be possible to use an uncompressed file which is not embedded in the msi.

I asume that you create the msi file yourself (?)

When you use Wix to generate your msi, the customer can simply regenerate the whole msi after replacing the file (wix is free). Otherwise it should be possible to use an uncompressed file which is not embedded in the msi. In wix you have to add a media element without a cabinet attribute. The disadvantage is that you have to distribute two files, instead of a single msi.

Blog, To see if EXE installer launched an MSI installation; To check for Scenario: I need to install a new configuration file for the application. There is a solution using the registry and AppSearch tables. You have MSI file with a large file inside the MSI and your task is to replace this file with a smaller size file  I have the msi file to install anyconnect only, with no features such as host scan, telemetry, etc. enabled. What I would like to accomplish is to remove some of the setting check boxes or have them correctly set so that the user does not have to do anything except for install, click yes, and accept the license agreement.

IMHO this kind of scenario indicates a missing feature in the application being installed, and is easier to fix in the application than hacking around with the MSI.


Admin Image

Let me first say that a simple way to "solve" this for your users, is to tell them to run an Admin Installation of your MSI. This will essentially extract all the files from the internal CABs and put all files in the specified folder:

msiexec.exe /a myinstaller.msi TARGETDIR=C:\AdminImage

Your users can then go directly into the extracted folder structure and update the file in question and then map the directory to other PC's and install the MSI. There could be side effects to this relating to the file having a hash value in the MSI (to avoid spoofing), but in most cases it works fine.


Run XML XPath Query

New versions of deployment tools such as Installshield and Wix feature built-in support for running XPath queries during the installation and hence write sections dynamically.


Application Update

Setting up an application on a PC involves several steps. First there is the deployment of content to the machine - this should be done using an MSI, no question about it. However, in most advanced applications several "post installation configuration tasks" similar to this "config file update" are required.

It is almost always better to defer these configuration tasks until the application launch, rather than to implement features in the MSI. There are many reasons for this, but the most important being that only the application EXE will be guaranteed to run in the correct user context. MSI files can be run with system rights, a different user account or via some other mechanism.

What we generally recommend is to use the MSI to get all required content onto the PC. Then tag the registry to indicate to the application that it's the first launch (for updates, you can increment a counter or write the new version number to HKLM). Then the application can perform the final configuration steps in its startup routine. It can copy a default config.xml file from somewhere in %ProgramFiles% and copy it to the user profile. Then it can read required values from HKLM written by the MSI, and then update the config.xml file with these values.

In general: avoid configuration steps performed by MSI or any other setup mechanism. Concentrate on writing the required files and registry items to the machine, and then let the application itself set up a proper runtime environment. This will allow much better deployment control. It is better "Encapsulation" if you like. The MSI sends a "message" to the application via the registry, and the application knows "how to set itself up correctly" based on the messages.

Silent MSI installer (from EXE file), I have a small problem and I need your help. to the .exe file, at package option I have selected "Silent installation (simple progress and error handling)" and then clicked finish. What I want to do is to install this newly converted msi package silently. The solution is to set the silent command line for the . As Cosmin mentioned, you would need to update the information in File Table, CAB archives; modification to Components table could be required. Repackaging with the updated files and keeping the ProductCode is the simplest solution, if the number of files to update is more than 3–5.

You need to add an entry to the Media table, adding another medium with no cabinet file, and a LastSequence one more than the CAB file's last sequence. You then need to replace in the File table the file's sequence with the new file, and update all the other file attributes that may have changed.

How can I speed up MSI package install and uninstall?, Potentially high overhead per file (small files). Firstly it creates a restore point prior to install or uninstall (provided system restore Here is another article describing file extraction from MSI packages in simple terms. -being-created-​during-install · How can I eliminate the huge, cached MSI files in C:\Windows\​Installer? replace file in msi using orca (6) . I'm creating a installer for a c# windows project using VS 2008. I'm trying to write a custom action that copies a settings file from the source directory of the MSI file stored on a file server (e.g. \server\fileshare\myappinstaller\mysetting.xml) to the target directory on the computer on which my application is been installed (e.g. C:\Program Files\My App).

Check the following post: How to replace a file in a msi installer?

Where is mentionned:

This command extracts the MSI files: msi2xml -c OutputDir TestMSI.MSI

Open OutputDir and modify the file.

To rebuild the MSI run: xml2msi.exe -m TestMSI.xml

You need the -m to ignore the 'MD5 checksum test' that fails when an MSIs file(s) are modified.

Download: https://msi2xml.sourceforge.io/

Morphing Installers, But if we need more than one language, this simpler solution only allows us to create We can start our installation with a small bootstrapper. To create such a multi-language installer, there is surprisingly little to change: each localized installer to the base one (SampleMulti.msi) and creates an .mst transform file in turn  It is entirely possible to run an EXE file during an MSI install, and I have done so several times. It is just a matter of sequencing and verifying that the EXE you run exits cleanly. MSI is generally hard to deal with and often requires specialist attention, but the benefit in terms of corporate deployment is very substantial.

HWM, In fact, we did not need to change any settings on first boot-up - an important feature away the complexity with its simple-to-use BIOS and ready integrated peripherals. Although the same audio solution was used on the MSI 845 Pro2, IWILL's The latest Intel INF files version 3.20.1008 along with the Intel Application  Add files. The most important step in creating an MSI package is adding a file or folder. Switch to the “Files and Folders” page by selecting it in the left-side panel. The folders which interest you most are “Application Folder” and “Application Shortcut Folder”.

Windows Installer Best Practices, Instead you can use the Msistuff.exe tool to configure the Setup.exe Windows Installer packages should not attempt to replace protected Compress the files in the installation and store them in a cabinet (.cab) file . Limit the use of custom actions based on scripts to simple installation operations. There will be an example.msi in your folder now, congratulations! Double click it to install it, then go to Add/Remove Programs in the Control Panel where you can find an "Example Product Name". Don't forget to uninstall it, so you can later build and install a new MSI file. Create a simple application installer

Upgrade issue, Developers · Partners · Inside Symantec I tested that in small test msi. then your simplest solution is to change the cached MSI in c:\windows\installer So the question #1, is there a way I could find the file name from msi  Unique infinity and high-class golden design with rich specification. Win games and set records with 12+2+1 IR digital power, Mystic Light Infinity, Triple Lightning M.2 with Shield Frozr, Audio Boost HD, Game Boost and dual LAN with 2.5G gaming LAN plus WIFI 6 solution

Comments
  • Can you explain: MY_CONFIG is file what you want to replace and CAB_FILE is media file inside the MSI... correct?
  • In my case, I'm updating the global "default config" in the AllUsers/AppData folder. Copying to the per-user location happens at first launch. The configuration file is binary data in a proprietary format, it's not post-installation configuration at all - it's setting defaults for when the post-installation first-run configuration takes place (once a user config exists, the system default config is ignored). The question was originally asked as it's a simple drag/drop operation to do this in InstallShield, but we've migrated to WiX and needed to provide a easy way for our customers to do it.
  • This doesn't quite work, when adding a medium with no cabinet file I get "Error 2920. Source directory not specified for file <filename>" However it does work if I use a cabinet file. Suggestions?