0

I have a Wix installer who create an system DSN (ODBCDataSource component) from some parameters set by the user during installation.

        <Component Id="ODBCDATASOURCE" Guid="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" KeyPath="yes">
            <ODBCDataSource Id="ODBCDATASOURCE" Name="DBconnection" Registration="machine" DriverName="PostgreSQL Unicode" >
                 <Property Id="Database" Value="[ODBCDATABASENAME]" />
                 <Property Id="Server" Value="[ODBCSERVERIP]" />
                 <Property Id="Username" Value="[ODBCUSER]" />
                 <Property Id="Port" Value="5432" />
                 <Property Id="Password" Value="[ODBCPASSWORD]" />
            </ODBCDataSource>
        </Component

I have stored all these ODBCDataSource parameters in Registry keys to reused them during upgrade.

But if the user modified manually the ODBC configuration (for example to change the server IP address), my installer will not take this changes into account during upgrade as it reads properties values from Registry keys.

Is there a way for my installer to read properties from an existing OdbcDataSource instead of registry keys ?

Thanks for your help.

Breex
  • 1
  • 2
  • Yes, there is. Use a Custom Action written in C# to populate the properties: http://stackoverflow.com/questions/5728940/change-installer-properties-in-c-sharp-custom-action One side comment: I'm not convinced that storing server connection strings in the registry is a good idea... – ChristianMurschall Apr 28 '17 at 11:36
  • thanks for the link, i will have a look. – Breex May 02 '17 at 14:30
  • If you still have questions, do not hesitate to ask! its not a dumb question. – ChristianMurschall May 03 '17 at 12:04
  • As I don't now C# and never user external dll in custom action, I will need time to understand and practice this. But you put me on the right way. So for the moment, no other questions, thanks again. – Breex May 04 '17 at 12:44

1 Answers1

0

Finally, the solution was more easy than expected. I just read the ODBC values from the registry:

<Property Id="ODBCSERVERIP" Secure="yes">
  <RegistrySearch Id="SearchReg_ODBCSERVERIP" Type="raw" Root="HKLM" Key="Software\ODBC\ODBC.INI\DBconnection" Name="Servername" />
</Property>
<Property Id="ODBCDATABASENAME" Secure="yes">
  <RegistrySearch Id="SearchReg_ODBCDATABASENAME" Type="raw" Root="HKLM" Key="Software\ODBC\ODBC.INI\DBconnection" Name="Database" />
</Property>
<Property Id="ODBCUSER" Secure="yes">
  <RegistrySearch Id="SearchReg_ODBCUSER" Type="raw" Root="HKLM" Key="Software\ODBC\ODBC.INI\DBconnection" Name="Username" />
</Property>
<Property Id="ODBCPASSWORD" Secure="yes" Hidden="yes">
  <RegistrySearch Id="SearchReg_ODBCPASSWORD" Type="raw" Root="HKLM" Key="Software\ODBC\ODBC.INI\DBconnection" Name="Password" />
</Property>

This can also be done via custom action (read registry and set the value to a property), but this method is enough for me today.

Breex
  • 1
  • 2