Wix - How to get user input from a previously installed msi?

a 夏天 提交于 2019-12-11 00:07:33

问题


I'm trying to do an installer using wix 3.8. I can use custom properties to store my own input, but I'd like to use values that where inputs on a previously installed msi. Is there a way to accomplish such thing?.


回答1:


To get you in the right direction add this (of course adapt it to your needs first) in your fist MSI:

<DirectoryRef Id="INSTALLDIR">
  <Component Id="RegistryEntries" Guid="{0AC76129-F8E2-47D3-B9FD-09B1E10A8541}">
    <RegistryKey Root="HKLM" Key="Software\Company123\App123" Action="create">
      <RegistryValue Type="integer" Name="SomeIntegerValue" Value="1" KeyPath="yes"/>
      <RegistryValue Type="string" Name="UserInput" Value="[USERINPUT]" />
    </RegistryKey>
  </Component>
</DirectoryRef>

Don't forget reference the component in your <Feature> <ComponentRef Id="RegistryEntries" /> When you install assign a value to the property [USERINPUT] e.g. msiexec /i your.msi /qb+ USERINPUT="the value to be saved in registry"

Then in the second MSI add something like this:

   <Property Id="READREGISTRY">
       <RegistrySearch Id="USERINPUT_Value" Root="HKLM" Key="Software\Company123\App123" Name="UserInput" Type="raw" />
   </Property>

The value/string you entered during installation USERINPUT= will be stored in your second MSI in the property READREGISTRY

Here a piece of log in my second msi:

PROPERTY CHANGE: Adding READREGISTRY property. Its value is 'testing registry wef wef wef w'.

Based on your installation where it might be Per User or Per Machine you may adjust the Root to HKCU for PerUser installs or leave it to HKLM for PerMachine.

For more information please refer to Wix documentation, hints: "How To: Write a Registry Entry During Installation" and "How To: Read a Registry Entry During Installation".




回答2:


Generally, no. There is no requirement for a Windows Installer package to record the input it takes from the user. Some do record some information in the registry and you might choose to rely on finding it there.

As an alternative, you might find that the other installer can be run without a UI and can be sufficiently controlled with properties passed into it. If so, you can write your own UI (one way would be a custom WiX Bootrapper Application [example]) to gather the inputs before running the installer.




回答3:


Create a custom action within the MSI which gets installed first, then either write the values/user entries that you want into a file or registry. Within your final MSI read the values from registry/file and use it.

Here is an example of how you can read a value from the user and update the your app.config, this is not an apple to apple scenario, but this will guide you through it.

http://bensnose.blogspot.com/2013/03/more-custom-actions-with-wix.html

Disclaimer: I havent tried out what is mentioned in this blog post, but I have done things very similar and found that it has good explanation, thats why I posted the link to it.



来源:https://stackoverflow.com/questions/20648907/wix-how-to-get-user-input-from-a-previously-installed-msi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!