Delaying the Loading of Specific Services

On some systems, it may be necessary to delay the loading of specific services in order to allow those services to start successfully.  For example, on one of our servers, the Firebird service suddenly refused to start automatically when the system was rebooted.  We could start it manually but it would fail with error 1055 (service database is locked) when attempting to start automatically.

Apparently, the service database is always locked during the early phases of the boot process.  So, in order to get Firebird to start we needed to delay Windows’ attempts to automatically start the Firebird service.  To do this, you need to make Firebird dependent on another service.  If you do that, Windows will not try to start Firebird until that other service has started.  We chose to make Firebird dependent on the Server service since all systems must have the Server service running if you want to be able to do anything at all.

To make one service dependent on another you either need to write a program to modify the service’s configuration using the Services API or you can just modify the registry.   To configure the dependency by modifying the registry you need to take the following steps:

  1. Find the names of the two services involved.  This is not the name displayed in the Services control panel applet.  That is the display name not the actual name.  To get the actual name, right click the service and select Properties.  The actual name will be displayed near the top of the Properties window, next the the “Service Name” label.  In our case, the Firebird service name was FirebirdGuardianDefaulInstance and the Server service name was LanmanServer.
  2. Open the registry editor (regedit)
  3. Find the registry key for the service that you want to be dependent on the other service.  This will be HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\<service_name>.  In our case,  HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\FirebirdGuardianDefaultInstance.
  4.  Make a new multi-line string  (REG_MULTI_SZ) value under this key named DependOnService.
  5. Set the value of this value to the name of the service that you want this service to be dependent on.  In our case, LanmanServer.

That is all there is to it.

You can verify that you have set everything up correctly by right clicking the services involved in the Services applet and selecting Properties.  Then select the Dependencies tab.  In the dependent service you should see the service that it is dependent on listed under “This service depends on the following system components”.  In the other service you should see the dependent service listed under “The following system components depend on this service”.

Leave a Reply