Launch after install, with no UI?

前端 未结 4 729
灰色年华
灰色年华 2020-12-31 04:41

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 w

相关标签:
4条回答
  • 2020-12-31 05:26

    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>
    
    0 讨论(0)
  • 2020-12-31 05:30

    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>
    
    0 讨论(0)
  • 2020-12-31 05:32

    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.

    0 讨论(0)
  • 2020-12-31 05:38

    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.

    0 讨论(0)
提交回复
热议问题