title: Silent Installation of Application in a WiX Source File
body: <p>I want to install microsoft visual c++ 2008 redistributable package along with my msi installer. I decide to include it along with my installer as an application file and i wrote a golang code that triggers the silent installation of microsoft visual c++ 2008 redistributable package. The Service of my application starts only when microsoft visual c++ 2008 redistributable package is installed. I could see a uninstall option for my application in the Control panel but i couldnt see anything like that for the microsoft visual c++ 2008 redistributable package. And i am pretty sure that the package is not installed because my application never starts, when i trigger the silent.exe (as an administrator) alone which has the code to silently install the package it gets installed and my application works fine as well. The problem occurs when i try to pack everything in a single msi.</p>
  
  <p>The WiX Source file i wrote to include the silent.exe and also other necessary files i need for my application.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
  xmlns:util='http://schemas.microsoft.com/wix/UtilExtension'&gt;
  &lt;?include "CommonVariable.wxi"?&gt;
      &lt;Product Id="*" Language="1033" Manufacturer="Testing" Name="Testing_Name" Version="1.1.1"&gt;
          &lt;Package InstallerVersion="111" Compressed="yes" Description = "(x64 Edition) MSI Package"      Comments="(x64 Edition) MSI Package" InstallPrivileges="elevated" Platform="x64"/&gt;
              &lt;Media Id="1" Cabinet="product.cab" EmbedCab="yes"/&gt;
                  &lt;Directory Id="TARGETDIR" Name="SourceDir"&gt;
                      &lt;Directory Id="ProgramFilesFolder"&gt;
                          &lt;Directory Id="MYINSTALLLOCATION" Name="$(var.foldername)"&gt;
                              &lt;!-- Component for list of files to add in Installation location --&gt;
                              &lt;Component Id="ApplicationFiles" Guid="{**********-*******-*******-********}"&gt;
                                    &lt;File Id="ApplicationFile" Source="silent.exe"  Vital="no" DiskId="1" Hidden="yes"/&gt;
                                    &lt;File Id="ApplicationFile1" Source="Windows2008R2.exe" Vital="no" DiskId="1" Hidden="yes"/&gt;
                                        &lt;File Id="ApplicationFile1" Source="Myfiles" Vital="no" DiskId="1" /&gt;
                                    &lt;File Id="ApplicationFile1" Source="Myfiles" Vital="no" DiskId="1" /&gt;
                              &lt;/Component&gt;
  
                              ***other Actions for my Application***
  
                          &lt;/Directory&gt;
                      &lt;/Directory&gt;
                  &lt;/Directory&gt;
                  &lt;DirectoryRef Id="MYINSTALLLOCATION"&gt;
                    &lt;Component Id="CleanupMainApplicationFolder" Guid="{**********-*******-*******-********}" Win64="yes"&gt;
                      &lt;util:RemoveFolderEx On="uninstall" Property="MYINSTALLLOCATION" /&gt; 
                    &lt;/Component&gt;
                  &lt;/DirectoryRef&gt;
                  &lt;Property Id="MYINSTALLLOCATION" Value="$(var.InstallationLocation)" &gt;
                  &lt;/Property&gt;
                  &lt;Feature Id="DefaultFeature" Level="1"&gt;
                      &lt;ComponentRef Id="ApplicationFiles"/&gt;
                  &lt;/Feature&gt;
                  &lt;Binary Id="ExeId" SourceFile="silent.exe"/&gt;
  
                  &lt;CustomAction Id="SilentAction" BinaryKey="ExeId" ExeCommand="" Execute='deferred' Return   ='asyncWait' Impersonate='no'/&gt;
                  &lt;InstallExecuteSequence&gt;
                      &lt;Custom Action='SilentAction' Before='InstallFinalize'/&gt;
                  &lt;/InstallExecuteSequence&gt; 
  
      &lt;/Product&gt;
  &lt;/Wix&gt;
  </code></pre>
  
  <p>The Silent.exe is the golang code i wrote has many functions the part of the code i wrote to silently install the package is as below.</p>
  
  <pre><code>package main
  
  import (
      "fmt"
      "os/exec"
  )
  
  func main() {
      /*........................
      ...........................
      ..........................*/
      /*The code above is for my Different purpose */
      co := exec.Command("C:\\Windows2008R2.exe","/q","/c:\"msiexec","/i","Windows2008R2.msi","/qn","/l*v","C:\\Windows2008R2_x64.log\"")
      if err := co.Run(); err != nil { 
          fmt.Println("Error: ", err)
      }  
  }
  </code></pre>