Wix – How to run exe files after installation from installed directory?

The Isaiah4110 answer is not the best way if you don“t need a UI.

The simplest way to execute the exe file target you are installing through the MSI file produced by WiX is with a custom action type 18 (identifying the action by FileKey/FileRef), here you are a complete examples for v3/v4:

WiX v3:

<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
    <Component Id="TargetProgram" Guid="f757ff43-0266-483a-8749-ec796cba4b25" >
        <File Id="EXE" Source="C:\SetupProject\Includes\TargetProgram.exe" />
    </Component>
</ComponentGroup>

<CustomAction Id="EXECUTE_AFTER_FINALIZE"                  
              Execute="immediate" 
              Impersonate="no"
              Return="asyncNoWait"
              FileKey="EXE"
              ExeCommand="" />

<InstallExecuteSequence>
    <Custom Action="EXECUTE_AFTER_FINALIZE" After="InstallFinalize">NOT Installed</Custom>
</InstallExecuteSequence>
</Fragment>

WiX v4:

<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
    <Component Id="TargetProgram" Guid="f757ff43-0266-483a-8749-ec796cba4b25" >
        <File Id="EXE" Source="C:\SetupProject\Includes\TargetProgram.exe" />
    </Component>
</ComponentGroup>

<CustomAction Id="EXECUTE_AFTER_FINALIZE"                  
              Execute="immediate" 
              Impersonate="no"
              Return="asyncNoWait"
              FileRef="EXE"
              ExeCommand="" />

<InstallExecuteSequence>
    <Custom Action="EXECUTE_AFTER_FINALIZE" After="InstallFinalize" Condition="NOT Installed" />
</InstallExecuteSequence>
</Fragment>

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)