WiX Start application after install

Add-in Express™ Support Service
That's what is more important than anything else

WiX Start application after install
 
OliverM


Guest


I want to start my application right after installation has finished.
I want to do it the usual way by adding a 'Start MyApp' checkbox to the last dialog shown.
I found an example at http://wixtoolset.org/documentation/manual/v3/howtos/ui_and_localization/run_program_after_install.html but it uses the WixUI_Minimal dialog set which is different from what WixDesigner uses.
Can you please give advice on how to achieve my goal?
Posted 21 Feb, 2017 11:06:44 Top
Andrei Smolin


Add-in Express team


Posts: 18830
Joined: 2006-05-11
Hello Oliver,

Try to add the UI tag describing the UI set to the tags in the Product tag. Does it help?


Andrei Smolin
Add-in Express Team Leader
Posted 23 Feb, 2017 07:33:58 Top
OliverM


Guest


Hi Andrei,

Thanks for the reply. Would you please phrase your suggestion differently?
I do not understand what you mean.
Posted 23 Feb, 2017 07:51:43 Top
Andrei Smolin


Add-in Express team


Posts: 18830
Joined: 2006-05-11
Oliver,

I'll create a test project and provide it plus a description.


Andrei Smolin
Add-in Express Team Leader
Posted 23 Feb, 2017 09:57:04 Top
OliverM


Guest


Hi Andrei,

Thank you very much!
Posted 23 Feb, 2017 10:04:05 Top
Andrei Smolin


Add-in Express team


Posts: 18830
Joined: 2006-05-11
Oliver,

Let Add-in Express generate a WiX setup project for your add-in project. Use the WiX Designer's File System View to add the file to be run and accompanying files.

1. Make sure the Reference section of the setup project contains the files mentioned at http://wixtoolset.org/documentation/manual/v3/howtos/ui_and_localization/run_program_after_install.html:
WixUIExtension.dll
WixUtilExtension.dll

On my machine these files are located in C:\Program Files (x86)\WiX Toolset v3.10\bin\. Leave all other references intact.

2. Open Product.wxs and comment out the following UIRef tags:

    <UIRef Id="WixUI_InstallDir" />
    <UIRef Id="WixUI_ErrorProgressText" />


3. Paste the following tags; I took them from that page:

    <UI>
      <UIRef Id="WixUI_Minimal" />
      <Publish Dialog="ExitDialog" Control="Finish" Event="DoAction" Value="LaunchApplication">WIXUI_EXITDIALOGOPTIONALCHECKBOX=1 and NOT Installed</Publish>
    </UI>
    <Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Launch My Application" />
    <!-- Step 3: Include the custom action -->
    <Property Id="WixShellExecTarget" Value="[#myapplication.exe]" />
    <CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="no" />


4. In the code of Product.wxs, locate the File tag describing the file to be run and copy the value of the ID attribute (without quotation marks). Now, modify the WixShellExecTarget property (it's part of the piece just pasted) with that ID as follows:

Before:
<Property Id="WixShellExecTarget" Value="[#myapplication.exe]" />


After
<Property Id="WixShellExecTarget" Value="[#{the ID of the File component}]" />


In my case, the Id is "_3D06B6FE_DFDC_42BA_B1EB_2011387F6296", I find it in this fragment of Product.wxs:

    <Directory Id="TARGETDIR" Name="SourceDir">
      <!-- The "MyAddin38" project output. -->
      <Component Id="comp_D2D7B961_F9CC_468A_BE70_05746AE63C19" Guid="FFFED3A5-5925-4A57-A401-814DB3A7F386" Permanent="no" SharedDllRefCount="no" Transitive="no">
        <File Id="_3D06B6FE_DFDC_42BA_B1EB_2011387F6296" DiskId="1" Hidden="no" ReadOnly="no" TrueType="no" System="no" Vital="yes" Name="myapplication.exe" Source="......myapplicationinDebugmyapplication.exe" KeyPath="yes" />
      </Component>
      ...


Accordingly, I have to modify the WixShellExecTarget property as follows:

<Property Id="WixShellExecTarget" Value="[#_3D06B6FE_DFDC_42BA_B1EB_2011387F6296]" />


The above-mentioned page says that "the special # character tells WiX to look up the full installed path of the file with the id specified" (in my case ID="_3D06B6FE_DFDC_42BA_B1EB_2011387F6296").

The project is located at http://temp.add-in-express.com/support/MyAddin38-WixSetupRunAppAfterInstall.zip.


Andrei Smolin
Add-in Express Team Leader
Posted 24 Feb, 2017 02:20:42 Top
OliverM


Guest


Hi Andrei,

Thank you for the example project. Unfortunately the sample only works if the setup UI is not changed in any way.

Please try to reproduce the following:
Add a Welcome dialog to the project. (This will add a Finished dialog as well.)
Try to recompile - process fails with
LGHT0091: Duplicate symbol 'Dialog:FilesInUse' found. This typically means that an Id is duplicated. Check to make sure all your identifiers of a given type (File, Component, Feature) are unique.

Next delete the Welcome dialog and recompile => same error!
Next delete the Finished dialog and recompile => same error!

Why it is complaining id's are duplicated? I haven't changed a single code line manually. All I did was adding and deleting 2 dialogs.

Can you confirm the behaviour?
Posted 24 Feb, 2017 08:11:38 Top
Andrei Smolin


Add-in Express team


Posts: 18830
Joined: 2006-05-11
Hello Oliver,

The point is: the WiX designer uses a UI set of its own. Now you need to modify the Finished dialog so that it shows (or not) the check box and triggers the custom action if required.

I'll try to create such a project and let you know. This may take a while.


Andrei Smolin
Add-in Express Team Leader
Posted 28 Feb, 2017 06:58:10 Top
Andrei Smolin


Add-in Express team


Posts: 18830
Joined: 2006-05-11
Hello Oliver,

Preconditions: You've let Add-in Express create a WiX setup project, added an executable to be started when the installation is over. Using the UI Editor to add a dialog to the installer's UI, also adds the FinishedForm dialog to the Product.wxs; search the string below in Product.wxs. You need to create an optional check box on that dialog.

<Dialog Id="FinishedForm"

1. Add a checkbox control onto the dialog:

        <Control Id="OptionalCheckBox" Type="CheckBox" X="9" Y="212" Height="33" Width="354" Text="{VSI_MS_Sans_Serif13.0_0_0}[MYFINISHEDFORMOPTIONALCHECKBOXTEXT]" TabSkip="no" Property="MYFINISHEDFORMOPTIONALCHECKBOX" CheckBoxValue="1">
          <Condition Action="show"><![CDATA[REMOVE="" and NOT Installed]]></Condition>
          <Condition Action="hide"><![CDATA[REMOVE<>"" OR Installed]]></Condition>
        </Control>


2. Modify the Y position of the UpdateText control to give room for the check box:

Replace
<Control Id="UpdateText" Type="Text" X="9" Y="216"

with
<Control Id="UpdateText" Type="Text" X="9" Y="180"

3. Define an event (LaunchApplication) to fire when the form is being closed, but only if the check box is selected:

        <Control Id="CloseButton" Type="PushButton" X="300" Y="261" Width="66" Height="18" Text="{VSI_MS_Sans_Serif13.0_0_0}&amp;Close" TabSkip="no" Default="yes" Cancel="yes">
          <Publish Event="EndDialog" Value="Return"><![CDATA[1]]></Publish>
          <Publish Event="DoAction" Value="LaunchApplication">MYFINISHEDFORMOPTIONALCHECKBOX=1 and NOT Installed</Publish>
        </Control>


4. Comment out the WIXUI-related leftover:

    <!--<UIRef Id="WixUI_InstallDir" />
    <UIRef Id="WixUI_ErrorProgressText" />-->
    <!--<Property Id="WIXUI_INSTALLDIR" Value="TARGETDIR" />-->


5. Paste definitions of properties and a custom action; "_08B3E679_5E32_4EEE_9CAE_51D02931A592" below is the ID of a File tag describing the executable to be started.

[CODE] <Property Id="MYFINISHEDFORMOPTIONALCHECKBOXTEXT" Value="Launch My Application" />
<Property Id="MYFINISHEDFORMOPTIONALCHECKBOX" Value="1" />
<Property Id="WixShellExecTarget" Value="[#_08B3E679_5E32_4EEE_9CAE_51D02931A592]" />
<CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="no" />

6. Finally, make sure the setup project contains a reference to WixUtilExtension; it provides the WixCA custom action.

The UI modification thing above isn't ideal; I hope you'll get the idea and modify the form the way you want.


Andrei Smolin
Add-in Express Team Leader
Posted 02 Mar, 2017 09:35:30 Top
OliverM


Guest


Hi Andrei,

Thank you very much I got it working!
Posted 06 Mar, 2017 07:30:41 Top