I'm dealing with a circular dependency w.r.t. a Windows service and its dependence upon a driver. The situation is as follows:
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.
In early testing I would install the service via a command-line call to the service executable with the /INSTALL
flag -- this would call InstallService
internally.
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.
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 @ HKLM\System\CurrentControlSet\Services\<SERVICE>
in the DependOnService
value. This fixed that issue.
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 ServiceInstall
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.
If I don't specify the dependency in the installer configuration file then the service installs and runs fine.
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!
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.
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 need 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?
I've been wrestling with this and researching for at least a week; any insight would be appreciated.
Environment Info:
- Development: Windows 7, 32-bit
- Visual Studio 2010
- WiX v3.8
- Deployment: Windows 7, 32-bit and 64-bit -- CUSTOM, STRIPPED-DOWN IMAGES so something standard might not be present