Passing REINSTALLMODE to an MSI file
Asked Answered
K

2

7

I am using VisualStudio2005 and a vdproj to create a simple MSI file. I need to pass in the REINSTALLMODE property when I launch it.

I know this can be done via command line, like so: msiexec.exe /i foo.msi REINSTALLMODE=amus

However, if a user chooses to click the msi directly (launching the wizard), the property is not passed. Is it possible to do this via the VS and vdproj?

Some options I've investigated:

  • When I build the MSI via VS, it also produces a setup.exe. Is there a way to pass the REINSTALLMODE property through this maybe?
  • I installed Orca, which allows me to view/edit the Property table of the MSI. I could add it this way, but then I'd have to add it every time I do an MSI build.

Thanks for any advice.

Kalmick answered 22/12, 2009 at 16:27 Comment(0)
P
4

Sadly, I can't find a way to set other MSI properties right in VStudio.

Nonetheless, one method that should work is this:

  1. Use Orca to create a transform (MST) that only change the property REINSTALLMODE. (In short, you edit the property & save as a new transform, then use the "Generate Transform" command to create the MST.)
  2. This transform can be applied directly to your MSI using the MSITRAN.EXE command (available in the same Windows Installer SDK where you found Orca).
  3. You could either: (a) find a way to have Visual Studio always run your MSITRAN command immediately after the MSI build, or (b) just run your MSITRAN manually (from a batch file or such) after building but before testing.
Puente answered 22/12, 2009 at 19:41 Comment(2)
(I should probably try to use WiX if this msi gets anymore complicated)Kalmick
Indeed, WiX gives you access to all the complexities of Windows Installer. But it is a bit of a learning curve. Good luck!Puente
C
9

I found a more automated way to do this.

Create a script named add_reinstall_prop.vbs(example) with the folowing:

set objArgs = WScript.Arguments
set o_installer = CreateObject("WindowsInstaller.Installer")
set o_database = o_Installer.OpenDatabase(objArgs(0), 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

Add a post-build event to your setup project calling the script with the following:

add_reinstall_prop.vbs $(BuiltOuputPath)

This will automatically add the desired entry to the built MSI. You can then check it with Orca to see the entry is now added automatically after build.

Caernarvonshire answered 23/12, 2011 at 18:13 Comment(1)
Thanks man it works like charm. I need to use double quotes for add_reinstall_prop.vbs "$(BuiltOuputPath)"Profane
P
4

Sadly, I can't find a way to set other MSI properties right in VStudio.

Nonetheless, one method that should work is this:

  1. Use Orca to create a transform (MST) that only change the property REINSTALLMODE. (In short, you edit the property & save as a new transform, then use the "Generate Transform" command to create the MST.)
  2. This transform can be applied directly to your MSI using the MSITRAN.EXE command (available in the same Windows Installer SDK where you found Orca).
  3. You could either: (a) find a way to have Visual Studio always run your MSITRAN command immediately after the MSI build, or (b) just run your MSITRAN manually (from a batch file or such) after building but before testing.
Puente answered 22/12, 2009 at 19:41 Comment(2)
(I should probably try to use WiX if this msi gets anymore complicated)Kalmick
Indeed, WiX gives you access to all the complexities of Windows Installer. But it is a bit of a learning curve. Good luck!Puente

© 2022 - 2024 — McMap. All rights reserved.