tags:

views:

320

answers:

5

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.

+1  A: 

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
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=1It doesn't work either.
deerchao
try going through the .msi directly instead of the setup.exe bootstrapper.
Franci Penov
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
+1  A: 

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'&gt;
   <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
I tried: <CustomAction Id="LaunchApplication" FileKey="mainExecutableFile" ExeCommand="" Execute="immediate" Impersonate="yes" Return="asyncNoWait" /> <InstallExecuteSequence> <Custom Action='LaunchApplication' After='InstallFiles'>LAUNCH_APP_ON_EXIT</Custom> </InstallExecuteSequence> 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
Thanks for your example. I added a property UPDATING_AUTOMATICALLY to control whether the custom action running or not.
deerchao
Then I pass UPDATING_AUTOMATICALLY=1 in command line.
deerchao
+1  A: 

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
A: 

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
A: 

In Actual Installer you can launh it in silen mode.

Markus