MAKEMSI quickly and reliably creates MSI files in a non-programmatic way
Have your say! Join the MAKEMSI discussion list or view archive! Suggest improvements. No question too simple or too complex.
[Bottom][Contents][Prev]: Making changes to existing databases[Next]: Dumping a Windows Installer database
Have your say! Join the MAKEMSI discussion list or view archive! Suggest improvements. No question too simple or too complex.
\->MAKEMSI Installs...->Available Frameworks->Making changes to existing databases->Invoking MSI Update Via Batch File

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>


Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006, 2007, 2008 & 2009 for the Windows SDK (Windows Installer) area.Please email me any feedback, additional information or corrections.
See this page online (look for updates)

[Top][Contents][Prev]: Making changes to existing databases[Next]: Dumping a Windows Installer database


MAKEMSI© is (C)opyright Dennis Bareis 2003-2008 (All rights reserved).
Sunday February 28 2016 at 3:45pm
Visit MAKEMSI's Home Page
Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006, 2007, 2008 & 2009 for the Windows SDK (Windows Installer) area.