Changing the Product Version During a Build

InstallShield 2012 Spring Express Edition

Although the product version number in an InstallShield project (.ise) file or a built .msi file cannot be changed through the command line, it can be done using VBScript. The code sample below changes the version number in either a built .msi file, or an .ise project file. Changing the .ise file causes all .msi files built from that .ise file to have that build number in them.

You need to change the C:\Test.msi and 3.54.0154 parts so that they reflect the .msi file (or the .ise file) and the product version that you want to use. You could update the script so that the VBScript accepts these parameters as command-line arguments or registry entry values.

Dim pInstaller

    Set pInstaller = CreateObject("WindowsInstaller.Installer")

 

    Dim pDatabase

    Set pDatabase = pInstaller.OpenDatabase("C:\Test.msi", 2)

 

    pSQL1 = "SELECT `Value` FROM `Property` WHERE `Property` = 'ProductVersion'"

 

    Dim pView1

 

    Set pView1 = pDatabase.OpenView(pSQL1)

    pView1.Execute

 

    Dim pRecord1

    Set pRecord1 = pView1.Fetch

 

    If (Not pRecord1 Is Nothing) Then

        pRecord1.StringData(1) = "3.54.0154"

    Else

        MsgBox "error"

    End If

 

    pView1.Modify 4, pRecord1

 

    pView1.Close

 

    pDatabase.Commit

 

    MsgBox "Done!"