1

I'm creating a dual mode installer with a checkbox to let the user start the application after installation.

When installed machine wide (admin mode) the app launches as expected.

When installed just for the user (non admin mode) the app does not launch:

Action ended 9:04:52: LaunchApplication. Return value 3. MSI (c) (F0:94) [09:04:52:151]: Note: 1: 2205 2: 3: Error MSI (c) (F0:94) [09:04:52:151]: Note: 1: 2228 2: 3: Error 4: SELECT `Message` FROM `Error` WHERE `Error` = 2896 DEBUG: Error 2896: Executing action LaunchApplication failed. The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2896. The arguments are: LaunchApplication, , 

I've had a look at this question which has the same error, but I already have my file name in square brackets:

<Property Id="WixShellExecTarget" Value="[#FILE_SweetApp.WPF.exe]" />

Any ideas?


Edit

This is the relevant code:

<?define MyPath="$(var.SolutionDir)MyApp.WPF\bin\$(var.Configuration)"?> <ComponentGroup Id="MyApp.WPF" Directory="APPLICATIONFOLDER"> <Component Id="MainExecutable" Guid="{my guid}"> <File Id="FILE_App.WPF.exe" Source="$(var.MyPath)\myapp.exe" /> </Component> ... </ComponentGroup> <Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Launch app when setup exits." /> <Property Id="WixShellExecTarget" Value="[#FILE_App.WPF.exe]" /> <CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" /> <UI> <Publish Dialog="ExitDialog" Control="Finish" Order="1" Event="DoAction" Value="LaunchApplication">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT installed</Publish> </UI> 

Edit 2

Although launching the app on installer completion does not work on fresh app installs, strangely enough it works when I'm updating the app.

I think it might be .NET version related, as this blog seems to have the same symptoms I'm having. According to that post the empty arguments to the custom action are red herrings, as the custom action most likely doesn't even run.

13
  • The log file should tell you more, but it looks like it just has an empty string for argument? For one thing you can change the last part of the condition to be Installed and not installed. Try that first and see if that matters. Commented Jun 4, 2019 at 23:50
  • No luck changing to Installed. I think you're right, the argument is an empty string so naturally it doesn't know what to launch. Commented Jun 5, 2019 at 15:52
  • Unfortunately I couldn't get this to work. I ended up removing the checkbox. Commented Jun 6, 2019 at 16:17
  • While trying to remove the checkbox it suddenly started working :/ Same code, didn't even restart Visual Studio. I don't have a clue why it wasn't working... Commented Jun 7, 2019 at 17:57
  • Well that is odd indeed. You didn't change the package's bitness did you? (64-bit). Let us know if you discover what it was. Do you still have a malfunctioning MSI? You can diff them using Dark.exe or another MSI tool. I will update later. Heading out. Commented Jun 7, 2019 at 18:32

2 Answers 2

1

Best Guess: Without seeing the source it is hard to guess what is wrong. I would say you probably have a mismatching reference between the WixShellExecTarget property value and the File Id of the file to launch?:

<..> <Property Id="WixShellExecTarget" Value="[#MyFile.exe]" /> <..> <File Id="MyFile.exe" Source="C:\MyFile.exe"> <..> 

WiX Documentation: There is a sample of this in the WiX documentation: WiX sample for application launch (for future reference for others).

Mock-Up Sample: Here is a sample based on the above link. You must first: (1) create new WiX 3 project, 2) add references to WixUIExtension.dll and WixUtilExtension.dll:

<?xml version="1.0" encoding="UTF-8"?> <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> <!--NOTE #1: Add an UpgradeCode GUID below --> <Product Id="*" Name="WiX Dialog Testing" Language="1033" Version="1.0.0.0" Manufacturer="Hobbit" UpgradeCode="PUT-GUID-HERE"> <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" /> <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." /> <MediaTemplate EmbedCab="yes" /> <UI> <UIRef Id="WixUI_Advanced" /> <!-- Folder redirect dialog events --> <Publish Dialog="InstallScopeDlg" Control="Next" Property="MSIINSTALLPERUSER" Value="1" Order="3">WixAppFolder = "WixPerUserFolder"</Publish> <Publish Dialog="InstallScopeDlg" Control="Next" Property="MSIINSTALLPERUSER" Value="{}" Order="2">WixAppFolder = "WixPerMachineFolder"</Publish> <Publish Dialog="InstallScopeDlg" Control="Next" Event="DoAction" Value="WixSetDefaultPerMachineFolder" Order="3">WixAppFolder = "WixPerMachineFolder"</Publish> <Publish Dialog="InstallScopeDlg" Control="Next" Event="DoAction" Value="WixSetDefaultPerUserFolder" Order="3">WixAppFolder = "WixPerUserFolder"</Publish> <!-- Launch application dialog event --> <Publish Dialog="ExitDialog" Control="Finish" Event="DoAction" Value="LaunchApplication">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish> </UI> <!-- Launch application constructs NOTE! Added 'Secure="yes"' --> <Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Launch My Application Name Test" Secure="yes" /> <Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOX" Value="1" Secure="yes" /> <!-- Checked by default = 1 --> <!--NOTE #2: Make Value match File Id in component / file entry below --> <Property Id="WixShellExecTarget" Value="[#MyFile.exe]" /> <CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" /> <!-- Folder redirect constructs --> <Property Id="ApplicationFolderName" Value="PerUserPerMachine" /> <Property Id="WixAppFolder" Value="WixPerMachineFolder" /> <Feature Id="ProductFeature" Title="WiX Dialog Testing" Level="1" /> <Directory Id="TARGETDIR" Name="SourceDir"> <Directory Id="DesktopFolder" /> <Directory Id="ProgramFilesFolder"> <!--NOTE #3: Make sure Directory Id is APPLICATIONFOLDER --> <Directory Id="APPLICATIONFOLDER" Name="WiX Dialog Testing"> <!--NOTE #4: Add a component GUID below, adjust source file path, set File Id --> <Component Feature="ProductFeature" Guid="PUT-GUID-HERE"> <File Id="MyFile.exe" Source="C:\MyFile.exe"> <Shortcut Id="AppDesktopShortcut" Name="WiX Dialog Testing" Directory="DesktopFolder" /> </File> <RegistryValue Root="HKCU" Key="Software\My Company\My Product" Name="installed" Type="integer" Value="1" KeyPath="yes" /> </Component> </Directory> </Directory> </Directory> </Product> </Wix> 
Sign up to request clarification or add additional context in comments.

9 Comments

I've added the code I think is relevant. What has got me confused is that it works when installed machine wide but not when installed for the user. When I hardcode the path for an .exe it works. I guess the path is wrong when installed for the user? But I thought [#FILE_App.WPF.exe] resolves to wherever that file gets installed?
See my other comment too (above). Could it be that you should try to use a different and simpler ID just to test? Try MyFile.exe instead.
Before that try on a clean virtual and check the log file if the file is actually scheduled for installation during per-user installation. Check the Formatted data type.
Um, what's a clean virtual? A clean virtual machine? It looks like the file is scheduled for installation: MSI (s) (68:B8) [09:04:46:780]: Component: MainExecutable; Installed: Absent; Request: Local; Action: Local. And it must find the file, because I can launch the app from the start menu after installation.
No luck with simpler id of MyFile.exe :/
|
0

The issue was the #FILE_App.WPF.exe value.

<Property Id="WixShellExecTarget" Value="[#FILE_App.WPF.exe]" /> 

For fresh per user installs the value was:

%userprofile%\AppData\Local\Programs\MySweetApp\MySweet.exe 

instead of the actual install location:

%userprofile%\AppData\Local\Apps\MySweetApp\MySweet.exe 

Hence the LaunchApplication custom action was not able to find the .exe and failed.

The solution was to create a custom property (ExeLocation) with the correct .exe location and use that for the custom action:

<Property Id="WixShellExecTarget" Value="[ExeLocation]" /> 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.