title: WiX - trying to figure out install sequences
body: <p>I'm installing a large app, and part of it is a custom written tool called "DbUpdateManager" to mass execute SQL scripts against our target database.</p>
  
  <p>Right now, the WiX 2.x install works - but it has one flaw: during install, I also install a couple of Windows services, which can be optionally started right away. Those however will fail, if the DbUpdateManager hasn't been run yet.</p>
  
  <p>So what I'm trying to accomplish is this:</p>
  
  <ol>
  <li>Install DbUpdateManager and my services from my MSI</li>
  <li>Run DbUpdateManager <em>BEFORE</em> any of the services start up</li>
  </ol>
  
  <p>My current WiX source looks something like this:</p>
  
  <pre><code>&lt;Directory Id='INSTALLDIR' Name='DbUpdMgr' LongName='DbUpdateManager' &gt;
    &lt;!-- DbUpdateManager component with the necessary files --&gt;
    &lt;Component Id='DbUpdateManagerComponent' Guid='...' DiskId='1'&gt;
       &lt;File Id='DbUpdateManagerFile' LongName='DbUpdateManager.Wizard.exe' 
             Name='DbUmWz.exe' src='DbUpdateManager.Wizard.exe'  KeyPath='no' /&gt;
    &lt;/Component&gt;
  
    &lt;!-- Component to install one of my Windows services --&gt;
    &lt;Component Id='InstallServiceComponent' Guid='...' DiskId='1'&gt;
       &lt;File Id='InstallServiceFile' LongName='MyService.exe' 
             Name='MyServic.exe' src='MyService.exe' KeyPath='yes'/&gt;
       &lt;ServiceInstall Id='InstallMyService' Name='MyService' 
                       Description='My Service' ErrorControl='normal' 
                       Start='auto' Type='ownProcess' Vital='yes' /&gt;
       &lt;ServiceControl Id='UninstallMyService' Name='MyService' 
                       Remove='uninstall' Wait='yes' /&gt;
    &lt;/Component&gt;
  
    &lt;!-- Feature for the DbUpdateManager referencing the above component --&gt;    
    &lt;Feature Id='DbUpdateManager' ConfigurableDirectory='INSTALLDIR' 
             AllowAdvertise='no' Description='DbUpdateManager' Level='1' 
             Title='Database Update Manager'&gt;
       &lt;ComponentRef Id='DbUpdateManagerComponent'/&gt;
    &lt;/Feature&gt;
  
    &lt;!-- Custom action for running DbUpdateManager --&gt;    
    &lt;CustomAction Id='RunDbUpdateManagerAction' FileKey='DbUpdateManagerFile' 
                  ExeCommand='' Return='asyncWait' /&gt;
  
    &lt;!-- Calling the custom action in the install sequence --&gt;    
    &lt;InstallExecuteSequence&gt;
        &lt;RemoveExistingProducts After='InstallInitialize' /&gt;
        &lt;Custom Action='RunDbUpdateManagerAction' 
                After='InstallFinalize'&gt;&amp;amp;DbUpdateManager=3&lt;/Custom&gt;
  </code></pre>
  
  <p>I inherited this WIX, and it works - but as I said - the DbUpdateManager gets called too late in the process (only "After=InstallFinalize") and thus the services will fail to start up properly at first (the run fine the second time around when you restart them manually after DbUpdateManager has run).</p>
  
  <p>I poked around the MSI documentation a bit and found a nice step called "StartServices", so my hunch was to just change my calling the custom action to this:</p>
  
  <pre><code>   &lt;InstallExecuteSequence&gt;
            &lt;Custom Action='RunDbUpdateManagerAction' 
                    Before='StartServices'&gt;&amp;amp;DbUpdateManager=3&lt;/Custom&gt;
  </code></pre>
  
  <p>Unfortunately, in this case, nothing at all happens - DbUpdateManager NEVER gets called....</p>
  
  <p>Any ideas why? Debugging the MSI/WiX stuff is really really tricky, and I can't seem to see the forest for the trees anymore....</p>
  
  <p>Thanks!
  Marc</p>
  
  <p>EDIT: The "RunDbUpdateManagerAction" is placed in the right position in the InstallExecuteSequence table in my MSI - right AFTER InstallServices and just BEFORE StartServices - and yet it doesn't work.... DbUpdateManager (a Winforms utility) does <em>not</em> show up during installation :-(</p>
  
  <p>EDIT 2: now my action appears to be executed and at the right time - unfortunately, I'm just not seeing my wizard :-( What I'm seeing is an error code "return value 1631" which means something like "MSI Service could not be started" - wtf ???</p>
  
  <p>MSI (s) (2C:D8) [20:53:36:383]: Doing action: RunDbUpdateManagerAction
  Action 20:53:36: RunDbUpdateManagerAction. 
  Action started at 20:53:36: RunDbUpdateManagerAction.
  MSI (s) (2C:D8) [20:53:36:383]: Doing action: StartServices
  Action 20:53:36: StartServices. Services are being started
  Action started at 20:53:36: StartServices.
  Action finished at 20:53:36: RunDbUpdateManagerAction. Return value 1631.</p>