Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WiX Burn: Reading LaunchTarget from Registry

Tags:

wix

burn

I'm new with WiX, and I'm trying to have my Bootstrapper launch my installed application when it completes. To accomplish this, I'm using

<Variable Name="LaunchTarget" Value="path_to_exe"/>

However, it is not easy for me to get the path to the executable. The reason for this is because I'm using <Chain> to install some pre-requisites and then an msi that actually installs my exe.

So to do this, the msi is writting the path to a known location in the registry, and then the bootstrapper reads it and uses it.

The problem is that when the bootstrapper reads the registry, the msi hasn't run yet, so it is unable to run the executable at the end.

Here's my WiX, if it helps:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:bal="http://schemas.microsoft.com/wix/BalExtension" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
    <Bundle Name="My Installation" UpgradeCode="a8964402-f3fc-4878-aafd-31ecda6b685e" Version="1.0.0.0">
        <BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense">
            <bal:WixStandardBootstrapperApplication LicenseFile="EULA.rtf"
                                                    ThemeFile="theme.xml"
                                                    SuppressOptionsUI="yes" />
        </BootstrapperApplicationRef>
        <Chain>
            <PackageGroupRef Id="NetFx40Redist"/>
            <ExePackage Id="OpenSSL" SourceFile="pre-requesite.exe" />
            <MsiPackage Id="myInstall" SourceFile="mySetup.msi" />
        </Chain>
        <util:RegistrySearch Root="HKLM"
                             Key="Software\myProgram"
                             Value="myEXEPath"
                             Variable="myEXEPath"
                             Result="value"
                             Format="raw" />
        <Variable Name="LaunchTarget" Value="[myEXEPath]"/>
    </Bundle>
</Wix>

So, in short, I'm trying to have the RegistrySearch run AFTER the MsiPackage installs. Can this be done? If not, what alternatives do I have?

As I side note, if I manually fill in the registry value before installation, everything works fine. This means that besides the order things are running in, everything is working fine.

like image 228
Rob Avatar asked Nov 11 '14 21:11

Rob


1 Answers

RegistrySearches run during the Detect operation. Custom BAs could run Detect after Apply, but that's not really an option since you're using the WixStandardBootstrapperApplication.

Lucky for you, WiX v3.9 added support for running the LaunchTarget already elevated, with the requirement that the path to the target .exe be in the registry under HKLM. So you would do this:

<BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense">
    <bal:WixStandardBootstrapperApplication LicenseFile="EULA.rtf"
                                            ThemeFile="theme.xml"
                                            SuppressOptionsUI="yes"
                                            LaunchTargetElevatedId="MyAEEId" />
</BootstrapperApplicationRef>
<ApprovedExeForElevation Id="MyAEEId" 
                         Key="Software\myProgram" Value="myEXEPath" />

Edit:

It looks like you are required to set LaunchTarget as well. Why doesn't your bundle know where it will be? You can just put in gibberish for LaunchTarget (WixStdBA will try the registry location first), but can't you use built-in variables and/or MsiProperty elements to locate the exe?

like image 108
Sean Hall Avatar answered Nov 15 '22 08:11

Sean Hall