How to Configure Service Dependencies in Windows 7 for Proper Startup Sequence


8 views

When working with multiple Windows services that rely on each other, proper dependency configuration becomes crucial. Many developers encounter situations where services start in incorrect orders, particularly during system boot. The classic example is a server application requiring a database service - if the database isn't ready, the server fails.

While the Services GUI doesn't allow setting dependencies through the interface, Windows stores this configuration in the registry. Here's how to modify it:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\YourServerService]
"DependOnService"=hex(7):44,\
  00,61,00,74,00,61,00,62,00,61,00,73,00,65,00,53,\
  00,65,00,72,00,76,00,69,00,63,00,65,00,00,00,00

Replace "YourServerService" with your actual service name and "DatabaseService" with the dependency service name. The hex values represent the Unicode string of the service name.

For a more straightforward approach without directly editing the registry:

sc config "YourServerService" depend= "DatabaseService"

This command sets the dependency through the Service Control Manager. Remember to:

  1. Run Command Prompt as Administrator
  2. Check exact service names using "sc query" first
  3. Multiple dependencies can be separated by forward slashes

After setting dependencies, verify them with:

sc qc "YourServerService"

Look for the "DEPENDENCIES" line in the output. You can also check through the Services GUI in the Dependencies tab.

For services that don't support proper dependency chains, consider using delayed start:

sc config "YourServerService" start= delayed-auto

This gives dependent services more time to initialize before starting.

For a web service requiring SQL Server:

sc config "MyWebService" depend= "MSSQLSERVER"
sc config "MyWebService" start= delayed-auto

This ensures SQL Server starts first and gives it adequate initialization time.


When managing services in Windows 7, you might encounter situations where Service B must start only after Service A is fully initialized. The graphical interface in Services.msc shows dependencies but doesn't allow modifying them - that's where command line tools come in handy.

The most reliable method is using the sc.exe utility from an elevated command prompt. Here's the exact syntax:

sc config "YourDependentService" depend= "RequiredService"

For example, to make Apache service depend on MySQL:

sc config "Apache2.4" depend= "MySQL57"

When your service depends on several others, separate them with forward slashes:

sc config "ApplicationServer" depend= "DatabaseService/MessageQueueService"

After setting dependencies, verify them with:

sc qc "YourServiceName"

Look for the "DEPENDENCIES" line in the output.

For advanced users, dependencies can be set directly in the registry at:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\YourService\DependOnService

Create a multi-string value (REG_MULTI_SZ) containing all dependent services.

  • Always create a system restore point before modifying services
  • Dependencies are case-sensitive
  • Service names must use their internal names (viewable in Services.msc)
  • The space after "depend=" is required in sc.exe command

If services still start in wrong order:

  1. Check for circular dependencies
  2. Ensure all service names are spelled correctly
  3. Verify services aren't set to delayed start
  4. Check system event logs for service startup errors