1

What is wrong in my code. I can't run app after I check"EXITDIALOGOPTIONALCHECKBOX" on "ExitDialog".

<UI>
  <UIRef Id='WixUI_Minimal'/>
  <Publish Dialog="ExitDialog" Control="Finish" Order="1" Event="DoAction" Value="LaunchInstalledExe">LAUNCH_APP_ON_EXIT</Publish>
</UI>

<Directory Id="TARGETDIR" Name="SourceDir">
    <Directory Id="APPLICATIONROOTDIRECTORY">
      <Directory Id="ProgramMenuFolder">
        <Directory Id="ApplicationProgramsFolder" />
      </Directory>
    <Directory Id="DesktopFolder" />
  </Directory>
</Directory>

<DirectoryRef Id="APPLICATIONROOTDIRECTORY">
  <Component Id="Test.exe" Guid="EF2B3E63-B797-47E6-A1AD-8221F13B6959">
  <File Id="Test.exe" Source="ApplicationFiles\Test.exe" KeyPath="yes" Checksum="yes"/>
</Component>
</DirectoryRef>

<Feature Id="MainApplication" Title="Main Application" Level="1">
  <ComponentRef Id="Test.exe" />
  <ComponentRef Id="ApplicationShortcut" />
  <ComponentRef Id="ApplicationDesktopShortcut" />
</Feature>

<InstallExecuteSequence>
  <Custom Action='ChangeDir' After='CostFinalize' >NOT Installed</Custom>
</InstallExecuteSequence>

<Fragment>
  <CustomAction Id="ChangeDir" Directory="APPLICATIONROOTDIRECTORY" Value="C:\\SampleFolder\"  />
  <CustomAction Id="LaunchApplication" FileKey="Test.exe" ExeCommand="" Execute="immediate" Impersonate="yes" Return="asyncNoWait" />

<CustomAction Id="LaunchInstalledExe"
     FileKey="Test.exe"
     ExeCommand="" 
     Execute="immediate" 
     Impersonate="yes" 
     Return="asyncNoWait" >
</CustomAction>
</Fragment>

<Fragment>

 <DirectoryRef Id="ApplicationProgramsFolder">
   <Component Id="ApplicationShortcut" Guid="FBE47082-5FC5-4861-B113-96BA9D30821F">
    <Shortcut Id="ApplicationStartMenuShortcut"
              Name="Test"
              Description="opis"
              Icon="logo.ico"
              Target="[APPLICATIONROOTDIRECTORY]\Test.exe"
              WorkingDirectory="APPLICATIONROOTDIRECTORY"/>
    <RemoveFolder Id="ApplicationProgramsFolder" On="uninstall"/>
    <RegistryValue Root="HKCU" Key="Software\Test" Name="Test" Type="integer" Value="1" KeyPath="yes"/>

    <!-- Uninstall Shortcut-->
  <Shortcut Id="UninstallProduct"
      Name="Uninstall Test"
      Target="[SystemFolder]msiexec.exe"
      Arguments="/x [ProductCode]"
      Description="Uninstall Test" />

  </Component>
</DirectoryRef>

<!-- desktop shortcut-->
<DirectoryRef Id="DesktopFolder">
  <Component Id="ApplicationDesktopShortcut" Guid="5c9b9050-3846-49c3-8484-910f49d4eddf">
    <Shortcut Id="desktopSC" Target="[APPLICATIONROOTDIRECTORY]\Test.exe"
              Directory="DesktopFolder" Name="Test" IconIndex="0" WorkingDirectory="APPLICATIONFOLDER" Icon="logo.ico" Advertise="no" />
    <RemoveFolder Id="ApplicationDesktopFolder" Directory="DesktopFolder" On="uninstall"/>
    <RegistryValue Root="HKCU" Key="SOFTWARE\Test" Name="Test" Value="1" Type="integer" KeyPath="yes" />
  </Component>
</DirectoryRef>
</Fragment>

When I rem line with 'Custom Action='ChangeDir'' app will lunch. I really need this Custom Action becouse in other custom action I run (below code) to change 'APPLICATIONROOTDIRECTORY'

<CustomAction Id="LicenseInfoCustomAction" BinaryKey="CustomActionBinary" DllEntry="ShowLicenseInfo" Execute="immediate" Return="check" HideTarget="yes" />
<Binary Id="CustomActionBinary" SourceFile="$(var.MyCustomAction.TargetDir)$(var.MyCustomAction.TargetName).CA.dll"/>

.

Please help.

Update:

Finally I find solution in this documentation: wix documentation

App starts even with administrator privileges.

1 Answers1

0

From the Dizzy Monkey

Conditionally launching the application after installation

There are two ways to add a checkbox to the final page of an installation in order to conditionally launch an application. The first is supported in WiX 3 without needing any changes to the original dialogs, but it has a major limitation.

The final dialog box (ExitDialog) has an optional checkbox that can be displayed, and the property tied to this checkbox can be used to conditionally launch the application. The following entries in the setup file will add this checkbox

<CustomAction Id="StartAppOnExit" FileKey="YourAppExeId" ExeCommand="" Execute="immediate" Impersonate="yes" Return="asyncNoWait" />
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Launch Sample App 1.0 when setup exits." />
<UI>
    <Publish Dialog="ExitDialog" Control="Finish" Order="1" Event="DoAction" Value="StartAppOnExit">WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT</Publish>
</UI>

After looking at your code, you seem to have two custom actions that start your Application, you will only need one (LaunchApplication).

In this part

<UI>
  <UIRef Id='WixUI_Minimal'/>
  <Publish Dialog="ExitDialog" Control="Finish" Order="1" Event="DoAction" Value="LaunchInstalledExe">LAUNCH_APP_ON_EXIT</Publish>
</UI>

Change the Publish dialog for:

  <Publish Dialog="ExitDialog" Control="Finish" Order="1" Event="DoAction" Value="LaunchApplication">WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT</Publish>
CheGueVerra
  • 7,849
  • 4
  • 37
  • 49
  • Thanks for answer but after change my code app still wont run. The problem is this line with custom action: 'NOT Installed' when I comment this app will start. But how to change install dir using custom action and run app after installation – Marcin Polska May 07 '15 at 16:52
  • Have a look at this answer here to change InstallDir http://stackoverflow.com/questions/11003336/what-is-the-usage-of-targetdir-and-installdir-in-wix – CheGueVerra May 07 '15 at 18:22