Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Launch after install, with no UI?

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.

like image 341
deerchao Avatar asked Dec 09 '09 04:12

deerchao


2 Answers

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>
like image 162
Wim Coenen Avatar answered Oct 02 '22 16:10

Wim Coenen


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>
like image 45
deerchao Avatar answered Oct 02 '22 15:10

deerchao