title: How can I define this dependency when installing a service
body: <p>I'm dealing with a circular dependency w.r.t. a Windows service and its dependence upon a driver. The situation is as follows:</p>
  
  <p>I wrote a Windows service in C++. This service depends on a DLL which installs a driver the first time it is loaded/used; the DLL uses the driver during operation thenceforth.</p>
  
  <p>In early testing I would install the service via a command-line call to the service executable with the <code>/INSTALL</code> flag -- this would call <code>InstallService</code> internally.</p>
  
  <p>Then I ran into an issue: the service would run when I started it manually, but when it was set to run automatically after boot it would start before the driver had been loaded and it would error because of this.</p>
  
  <p>To fix this, I set up a dependency for the service upon the driver -- Windows treats drivers similar to services -- in the service's registry entry @ <code>HKLM\System\CurrentControlSet\Services\&lt;SERVICE&gt;</code> in the <code>DependOnService</code> value. This fixed that issue.</p>
  
  <p>Fast-forward to deployment: I am using WiX to install and start the service. During installation, I want to set the driver up as a dependency of my service. However, if I define the driver as a dependency in the <code>ServiceInstall</code> element then WiX tries to start it before starting my service, thus my problem: WiX can't start the service without starting the dependency, and the dependency isn't there because the service hasn't run yet.</p>
  
  <p>If I don't specify the dependency in the installer configuration file then the service installs and runs fine.</p>
  
  <p>I figured that I could define the dependency after installing the service, in the registry like before, but there's no entry for the service there!</p>
  
  <p>Another thing: the service runs after boot now! Without having defined the dependency! I haven't done much testing to see if this is consistent or not.</p>
  
  <p>So, how does WiX tell Windows that there's a service, i.e. why is there no registry entry? How can I specify the dependency? Do I even <em>need</em> to specify one anymore? Should I forego using the WiX service-related elements and run the commands I did during testing manually in the installer?</p>
  
  <p>I've been wrestling with this and researching for at least a week; any insight would be appreciated.</p>
  
  <hr>
  
  <p><strong>Environment Info:</strong></p>
  
  <ul>
  <li>Development: Windows 7, 32-bit</li>
  <li>Visual Studio 2010</li>
  <li>WiX v3.8</li>
  <li>Deployment: Windows 7, 32-bit and 64-bit -- <strong><em>CUSTOM, STRIPPED-DOWN IMAGES</em></strong> so something standard might not be present</li>
  </ul>