visual-studiowindows-installer

Need a way to add one property to the msi properties table in setup project in VS2010


I've been using Orca to manually add property REINSTALLMODE with value amus into the MSI property table every time I build it.

I'm sick of this. I looked into Wix. But so far, I don't think it's worth the hassle to learn it/switch to it just yet, even though it will solve this problem. Is there a way I can automatically insert this one property into the MSI after the build is complete? Preferably, it will use only vanilla Visual Studio 2010 and not depend on third party programs or system environment variables.

Any thoughts?


Solution

  • use a vbscript

    change an existing property

    set o_installer = CreateObject("WindowsInstaller.Installer")
    set o_database = o_Installer.OpenDatabase("path_to_your_msi", 1)
    s_SQL = "SELECT Property, Value FROM Property Where Property = 'ReinstallMode'"
    Set o_MSIView = o_DataBase.OpenView(s_SQL)
    o_MSIView.Execute
    Set o_MSIRecord = o_MSIView.Fetch
    o_MSIRecord.StringData(2) = "amus"
    o_MSIView.Modify 2, o_MSIRecord
    o_DataBase.Commit
    

    add an new property

    set o_installer = CreateObject("WindowsInstaller.Installer")
    set o_database = o_Installer.OpenDatabase("path_to_your_msi", 1)
    s_SQL = "INSERT INTO Property (Property, Value) Values( 'ReinstallMode', 'amus')"
    Set o_MSIView = o_DataBase.OpenView( s_SQL)
    o_MSIView.Execute
    o_DataBase.Commit