Link to home
Start Free TrialLog in
Avatar of timyeung
timyeung

asked on

how to replace a file in a msi package

hi Experts,

To limit the concurrent use of a software we have purchased, it is needed to replace one of the .exe file with a locked version of same exe file in the msi package. besides, 3 files are needed to add to the same directory as the locked exe file. ( required by ElecKey network version ).

How to do it? It is a MUST to remove the original unlocked version of the exe from the msi package so that the receiver of the package can not bypass the lock easily.

--Tim
ASKER CERTIFIED SOLUTION
Avatar of SamHobbs
SamHobbs

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tsmtsm
tsmtsm

MSI databases are very complex and are not easily maintained, there are very few tools available that allow you the freedom to carry out what you request, the best thing you could do would be to purchase a copy of a professional installer like InstallShield (www.installshield.com) and get their tech support to help.

The tools that setup developers like myself use is MakeMSI (http://users.cyberone.com.au/dbareis/makemsi.htm) as well as orca(as mentioned by SamHobbs), these free tools allow you to carry out what you want but learning how to do it can be weeks of work as you will see by looking at the help files for MSI editors.

I don't want to discourage you but manual editing of MSI files are not as simple as being able to ask a question here as the MSI database needs to know things like:

What order the files need to be installed in,
What GUI, if any, is attached to the file,
Where they need to be installed
In what circumstance do they not get installed
What registry settings need to be altered
Licencing requirements

and the list goes on and on.
InstallShield might be good if the requirement is to create a setup system when the application to be installed is available, but when the only material that is available is the msi file and a new version of a exe file, then my guess is that InstallShield is useless. Is InstallShield relevant to this situation? If InstallShield is useful for this, then there are working demo copies that are (were) provided with many of the microsoft products such as VC. Can a demo copy be used?

Correspondingly, can MakeMSI be use to edit a msi file if all that is available is the msi file and a replacement exe?
As a msi file is just a header database of settings for Microsoft's installer to read and use and the exe is just a bootstrapper, then MakeMSI can make or adjust any msi file to do whatever you need it to.
The files associated with the msi database are just in a compressed format behind the header of settings, and can be manipulated through the installer's compression algorithm using MakeMSI.
The author, timyeung, can clarify things, but I think the "bootstrapper" is not the exe that timyeung needs to replace.
Avatar of timyeung

ASKER

Thanks SamHobbs,

Of course not,
the exe is the main problem inside the package.

I am trying to edit the msi, in the "Cabs" Table, i write the cab file, extract it, replace the exe and make a new cab file with CabArc. I edited the filesize of the exe inside the "File" Table and read the cab file back to the entry in the "Cabs" table

When i test the installation, the exe file installed is still the original exe, not the new one. Just wonder how the package still has the original file. What's wrong?

--Tim
Sorry i did not mean to imply that you were wanting to replace the bootstrapper exe, i was just explaining the associated files.

Installshield can be used for arbitary file installation, you can retrieve the original files from the MSI as you have done with a decompressor, but you will need to know what gets installed where, with what and what registry settings to add.

All files in the MSI file have a GUID (global unique identifier) and cannot be arbitarily changed as the mapping is against the GUID not the file name.

To change a file, a new MSI database would need to be created for correct GUID mapping, this can be done manually but it would take longer to make the changes than create a new one as you would have to change the advertised execute sequence as well as the install execute sequence mappings.

My advice is to purchase Installshield and start a new msi file from scratch using the Installshield UI.
the problems now are how to use the MakeCab or WiMakCab.exe to make the Cab file after replaced the exe in the extracted the files.
Great. It is Done.

As the original msi contain multiple Cabs, WiMakCab.vbs can't apply directly.
I modified the WiMakCab.vbs to handle for specific range of sequence inside "File" table only.

Simple problem should come with simple answer.

thanks to SamHobbs
Some details of the work done for referenence
- it needs orca, InstallerSDK and CoreSDK.
- in "File" table, find the file you want to replace, note the sequence number
- in the "Media" table, findout which Cabs contain the file, by the lastsequence
- in the "Cabs" table, write the binary data to a cab file, say w1.cab
- extract the cab.
- replace the file.
- modify the WiMakCab.vbs so that
       -it handle a range of sequence number in the file table only. it would be the range of sequence number contain in the cab file you replacing,
       - and ignore the "SourceDir" and use "optional source"
- run WiMakCab.vbs <msi> <base> <dir contain the extracted file>
- makecab /f <ddf file generated>
- in orca, write the binary data back with the cab generated
- saveAs to msi package
I am sorry I was not able to help you more; I would have if I could.