Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect SQL Server Express in WiX installer

How do I detect if Sql Server Express is installed and running on a machine in a WiX installer?

I want to check before installing my application and if it's not installed and running, to inform the user that it has to be installed first before installing my application.

like image 657
Krzysztof Kozmic Avatar asked Mar 26 '09 08:03

Krzysztof Kozmic


People also ask

Where is SQL Express database located?

The system database files for the database are stored in the local AppData path, which is normally hidden. For example, C:\Users\<user>\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\LocalDBApp1\ .


3 Answers

I tried Krzysztof's solution (above) - but on some machines when using this approach it wasn't correctly detecting when they did not have Sql Express installed.

It looked to be caused by mishandling of the REG_MULTI_SZ InstalledInstances registry value?

As I was checking to see if I needed to stop/restart the Sql Server Express service in the installer, I decided to just check against that instead - so here's my alternative, where I just check for the service instead:

<Property Id="SQLEXPRESSINSTALLED" >
  <RegistrySearch Id="IsSqlExpressServiceInstalled" Root="HKLM" Key="SYSTEM\CurrentControlSet\services\MSSQL$SQLEXPRESS" Name="Description" Type="raw" Win64="no"/>
</Property>      

<Condition Message="Express Not Installed">SQLEXPRESSINSTALLED</Condition>

<Condition Message="Express Installed">NOT SQLEXPRESSINSTALLED</Condition>

Bit of a hack, but seems to work well enough for our customers (were using the conditions within components, rather then the example Launch conditions shown above)

like image 97
Bittercoder Avatar answered Oct 19 '22 09:10

Bittercoder


The accepted answer above was always passing the condition for me. I got it working using:

<Property Id="SQLSERVER_INSTANCE">
  <RegistrySearch Id="SQLServerRegSearch" Root="HKLM" Key="SOFTWARE\Microsoft\Microsoft Sql Server\Instance Names\SQL" Type="raw" Name="SQLEXPRESS"/>
</Property>
<Condition Message="You don't have SQL Server installed.">
  <![CDATA[SQLSERVER_INSTANCE]]>
</Condition>
like image 33
patrickbadley Avatar answered Oct 19 '22 09:10

patrickbadley


Ok, I found by trial and error option that works:

<Property Id="SQLSERVER">
  <RegistrySearch Id="SQLServer" Root="HKLM" Key="SOFTWARE\Microsoft\Microsoft Sql Server" Type="raw" Name="InstalledInstances"/>
</Property>

I define a registry search, and then check its value:

<Condition Message="You don't have SQL Server installed.">
  <![CDATA[SQLSERVER >< SQLEXPRESS]]>
</Condition>
like image 20
Krzysztof Kozmic Avatar answered Oct 19 '22 11:10

Krzysztof Kozmic