Invoking MSI Update Via Batch File |
Someone asked how they could use the same MSI but install multiple instances, this is something that will need a lot of testing and exactly what you will need to do (if possible at all) will vary from MSI to MSI but this request makes a good example.
I'd be very careful about any shared resources (files, registry, shortcuts etc), make sure uninstalling one doesn't package doesn't remove them for everyone.
NewMsi.CMD |
The following is a batch file for WINNT+ which specifies the MSI your wish to modify and the modified MSI to be created (the pause is so you can see the results if you double click in explorer):
@echo off setlocal set SpecifyTemplateMsi='/Define:TemplateMsi=Template.msi' set SpecifyNewMsi='/Define:NewMsi=NewProduct.MSI' set NewProductName='/Define:NewProductName=MyProduct #1' set MAKEMSI_MM=%SpecifyTemplateMsi% %SpecifyNewMsi% %NewProductName% call MM.CMD NewMsi.MM P echo. pause
In the above batch we create some PPWIZARD "macros" to pass required details to the "NewMsi.MM" script (below).
The batch file is meant to show you how to invoke MAKEMSI and probably not how you'd want to actually do it, for example you may wish to have the batch file (or MAKEMSI script for that matter) prompt the user for the value.
NewMsi.MM |
The batch file above should be used to invoke this script:
;--- Check this script was invoked correctly -------------------------------- #ifndef NewProductName #error ^Expected "NewProductName" to be defined (script not correctly invoked)^ #endif #ifndef NewMsi #error ^Expected "NewMsi" to be defined (script not correctly invoked)^ #endif #ifndef TemplateMsi #error ^Expected "TemplateMsi" to be defined (script not correctly invoked)^ #endif ;--- Load MAKEMSI support for changing MSIs --------------------------------- #include "OpenMsi.MMH" ;--- Start new MSI (using the "old" as a template) -------------------------- <$Msi '.\<$NewMsi>' Template='.\<$TemplateMsi>'> ;--- New Random GUIDs for package/product related codes ----------------- <$Property "ProductCode" *Value='GuidMake("")'> <$Property "UpgradeCode" *Value='GuidMake("")'> <$Summary "PackageCode" *Value='GuidMake("")'> ;--- Change all component GUIDs ----------------------------------------- <$Table "Component"> <$Row @Where="" @OK='>0' *ComponentId='GuidMake("")'> <$/Table> ;--- Make sure files install elsewhere (off "C:\Program Files")! -------- <$Table "Directory"> <$Row @Where="Directory = 'INSTALLDIR'" @OK='=1' *DefaultDir=^MakeSfnLfn("ANYTHING", "<$NewProductName>")^> <$/Table> ;--- Change the Product Name -------------------------------------------- <$Property "ProductName" Value='<$NewProductName>'> ;--- Flag change times -------------------------------------------------- <$Summary "EDITTIME" VALUE="now()"> <$Summary "LASTSAVE_DTM" *VALUE="now()"> <$/Msi>