WiX Burn: Reading LaunchTarget from Registry
Asked Answered
E

1

5

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.

Excrete answered 11/11, 2014 at 21:37 Comment(0)
D
7

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?

Drowsy answered 12/11, 2014 at 0:58 Comment(1)
Wow, I'm extremely lucky I see since it just came out 12 days ago! I upgraded WiX and added the two Elevation things and it worked great. Thank you very much!!! And to answer your question, the bootstrapper doesn't have the path because it is decided by mySetup.msi. I set a default in the msi, and I could hardcode that into the bootstrapper, but if the user changes the path then it won't work.Excrete

© 2022 - 2024 — McMap. All rights reserved.