17

How do I launch my application after install with no UI (or in quiet mode)? Thanks!


I had a installer with UI which has an option to run after install. Now I want my application to updates itself by downloading and running the new version of installer in quiet mode, but after updating done, it won't launch again.

deerchao
  • 10,454
  • 9
  • 55
  • 60
  • Note: I'm using a property named LAUNCHAPPONEXIT to control the custom action which launches my application. And its default value is 1. – deerchao Dec 09 '09 at 06:15
  • Here is the approach I'm using for launch after setup: http://www.dizzymonkeydesign.com/blog/misc/adding-and-customizing-dlgs-in-wix-3/ – deerchao Dec 09 '09 at 07:00

4 Answers4

15

From the msdn topic on sequencing custom actions:

As in the case of standard actions, custom actions that are scheduled in the InstallUISequence or AdminUISequence run only if the internal user interface is set to the full level.

So I guess your custom action is scheduled in a UI sequence, not in InstallExecuteSequence. Try scheduling your custom action in the InstallExecuteSequence like this:

  <InstallExecuteSequence>
     <Custom Action='LaunchApplication' After='InstallFiles'/>
  </InstallExecuteSequence>

where "LaunchApplication" should be replaced by the Id of your CustomAction element.

edit: I looked at the instructions that you followed, and I don't see the custom action for launching the application being scheduled in any sequence. It is only triggered from a UI action (clicking the Finish button). This explains why it is never executed during a silent install.

edit: full sample (it's a bit sloppy as it also tries to execute the custom action on uninstall, repair etc. but for some reason I couldn't get the "NOT Installed" condition to work)

<?xml version='1.0' encoding='utf-8'?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
   <Product
         Name='ProductName'
         Id='*'
         Language='1033'
         Version='0.0.1'
         Manufacturer='ManufacturerName' >
      <Package
            Keywords='Installer'
            Description='Launch application demo'
            Manufacturer='ManufactererName'
            InstallerVersion='100'
            Languages='1033'
            Compressed='yes'
            SummaryCodepage='1252'/>

      <Media Id='1' Cabinet='test.cab' EmbedCab='yes'/> 

      <Directory Id='TARGETDIR' Name="SourceDir">
         <Directory Id='ProgramFilesFolder'>
            <Directory Id='TestFolder' Name='Test' >
               <Component Id="ExeComponent" Guid="*">
                  <File Id="ExeFile" Source="c:\windows\notepad.exe" />
               </Component>
            </Directory>
         </Directory>
      </Directory>

      <Feature Id='Complete'
            Display='expand'
            Level='1'
            Title='Test'
            Description='Test'>
         <ComponentRef Id="ExeComponent" />
      </Feature>

      <InstallExecuteSequence>
         <Custom Action='LaunchInstalledExe' After='InstallFinalize'/>
      </InstallExecuteSequence>

      <CustomAction Id="LaunchInstalledExe"
         FileKey="ExeFile"
         ExeCommand="" 
         Execute="immediate" 
         Impersonate="yes" 
         Return="asyncNoWait" />

   </Product>
</Wix>
Wim Coenen
  • 66,094
  • 13
  • 157
  • 251
  • I tried: LAUNCH_APP_ON_EXIT It seems I can't make it work, with or without UI, even if I took out the condition LAUNCH_APP_ON_EXIT. Can you provide a simple example that works? Thanks! – deerchao Dec 12 '09 at 00:51
  • Thanks for your example. I added a property UPDATING_AUTOMATICALLY to control whether the custom action running or not. – deerchao Dec 12 '09 at 08:03
  • Using worked but the only problem is that application opens under the FileExplorer window. I have to minimize FileExplorer to see the application. Is there anyway to force the launched application to appear on top? – Saeid Nourian Jul 16 '15 at 15:45
4

In my final solution I used two properties, one for UI (LAUNCH_APP_ON_EXIT), one for command line arguments (UPDATING_AUTOMATICALLY).

I have to do this because if I run the CustomAction after InstallFinalize in full UI mode, the application would start before you click the "Finish" button.

Now I can call setup.exe /qn UPDATING_AUTOMATICALLY=1 in my program to update.

Here is it all:

<Property Id="LAUNCH_APP_ON_EXIT" Value="1" />
<Property Id="UPDATING_AUTOMATICALLY" Value ="0" />

<CustomAction Id="LaunchApplication" FileKey="mainExecutableFile" ExeCommand="" Execute="immediate" Impersonate="yes" Return="asyncNoWait" />

<UI>
    <!-- explainations: http://www.dizzymonkeydesign.com/blog/misc/adding-and-customizing-dlgs-in-wix-3/ -->
  <UIRef Id="MyWixUI_InstallDir" />
  <UIRef Id="WixUI_ErrorProgressText"/>

  <Publish Dialog="MyExitDialog" Control="Finish" Order="1" Event="DoAction" Value="LaunchApplication">LAUNCH_APP_ON_EXIT</Publish>
</UI>

<InstallExecuteSequence>
  <Custom Action='LaunchApplication' After='InstallFinalize'>UPDATING_AUTOMATICALLY = 1</Custom>
</InstallExecuteSequence>
deerchao
  • 10,454
  • 9
  • 55
  • 60
  • This was very helpful. In my situation I wanted to use the standard UI checkbox to launch the program *if* UI was displayed... but if the install was run silently I wanted to automatically launch it. Adding the UPDATING_AUTOMATICALLY property to the section was crucial. Thanks! – stuzor Jan 22 '17 at 23:20
1

I would assume that you are launching your app from a custom action, which is triggered through a property bound to the checkbox. If that is the case, you can try specifying that property as a command line argument to setup.exe. Say, if your custom action is bound to the MSI property LAUNCH_NEW_VERSION, you can call setup.exe like this:

setup.exe /q LAUNCH_NEW_VERSION=1

The standard setup bootstrapper should pass that property/value to the MSI engine. If it doesn't, you might consider invoking the .msi directly instead of calling the bootstrapper exe to run your installer.

Franci Penov
  • 74,861
  • 18
  • 132
  • 169
  • Yes, I'm using a property named LAUNCHAPPONEXIT to control the custom action, and its default value is set to 1. But the program won't be started in quiet mode any how. I tried setup.exe /q LAUNCHAPPONEXIT=1 It doesn't work either. – deerchao Dec 09 '09 at 06:11
  • try going through the .msi directly instead of the setup.exe bootstrapper. – Franci Penov Dec 09 '09 at 07:25
  • I tried several times with no luck: "msiexec /i DepotM.Setup.msi /qn LAUNCHAPPONEXIT=1" However if I change to /qf (which shows the full ui) it runs after the installation. /qb didn't work either. – deerchao Dec 09 '09 at 07:49
1

This is the approach I took.

<Property Id="WixShellExecTarget" Value="[#(the id of your exe here)]" />
<CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />

This will execute which ever file id you enter in the Value. The [# ] is needed. I used this and ran it via the UI but you should be able to call this custom action anywhere and it work.

Scott Boettger
  • 3,657
  • 2
  • 33
  • 44