WiX Toolset - How to determine the SQL Server DATA path

442 Views Asked by At

I've tried to do this a few ways. Here's my latest attempt, which does not work, but should help illustrate what I'm looking to do.

Note: My assumption for the GetSQLServerInstalledInstance Id is that it will return one instance.

My goal is to find the DATA directory path for an instance of SQL Server installed on the machine that will also be installing my companies product.

<util:RegistrySearch Id='GetSQLServerInstalledInstance'
    Variable='SQL_SERVER_INSTALLED_INSTANCE'
    Root='HKLM'
    Key='SOFTWARE\Microsoft\Microsoft SQL Server'
    Value="InstalledInstances"
    Format="raw" />
<util:RegistrySearch Id='GetSQLServerInstalledInstanceName'
    Variable='SQL_SERVER_INSTALLED_INSTANCE_NAME'
    Root='HKLM'
    Key='SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL'
    Value="[SQL_SERVER_INSTALLED_INSTANCE]"
    Format="raw"
    After="GetSQLServerInstalledInstance" />
<util:RegistrySearch Id='GetSQLServerInstallPath'
    Variable='SQL_SERVER_INSTALL_PATH'
    Root='HKLM'
    Key='SOFTWARE\Microsoft\Microsoft SQL Server\[SQL_SERVER_INSTALLED_INSTANCE_NAME]\Setup'
    Value="SQLPath"
    Format="raw"
    After="GetSQLServerInstalledInstanceName" />
<SetProperty Id='SQL_SERVER_FILE_PATH' Value="[SQL_SERVER_INSTALL_PATH]\DATA" After="CostFinalize" Sequence="first" />

In the end, I'm looking for the SQL_SERVER_FILE_PATH property to contain this path. (e.g. C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA)

It's also important that the calls are sequenced at that subsequent calls can contain information derived from previous calls.

I'm still fairly new to WiX, but I could imagine how to do this pretty easily if the SetProperty element allowed a RegistrySearch child element to set it's value. Can this be handled by a sequence of CustomActions that would act similar to a SetProperty element that allows a RegistrySearch child element to set it's value?

Thanks

1

There are 1 best solutions below

0
On

I found a simpler method for determining the SQL Server DATA directory path using WiX. For future reference, this was how I solved this:

<Property Id='SQL_SERVER_INSTALL_PATH'>
    <RegistrySearch Id='GetSQLServerInstallPath' Root='HKLM'
                    Key='SOFTWARE\Microsoft\MSSQLServer\Setup'
                    Name='SQLPath' Type='directory' Win64="yes" />
</Property>
<SetProperty Id='SQL_SERVER_DATA_PATH' Value="[SQL_SERVER_INSTALL_PATH]DATA" After="CostFinalize" Sequence="first" />

Hope this helps others