When You'll See This Error
You're setting up a new service on Windows Server 2019 or 2022—maybe a third-party backup agent or a custom Windows service you wrote in-house. You run sc create with a depend= flag pointing to an existing service like LanmanServer. Suddenly you get:
ERROR_DEPENDENCY_ALREADY_EXISTS 0X0000138B
This also happens when you try to add a dependency through the Service Control Manager GUI (services.msc) and the dependency string already exists in the registry. I've seen it most often when someone tries to make Service A depend on Service B twice—either manually or via a script that ran twice.
What's Actually Going On
The dependency list for a service is a single REG_MULTI_SZ value stored under HKLM\SYSTEM\CurrentControlSet\Services\[YourService]\DependOnService. Each dependency is one string entry. If you add a dependency that's already in that list, Windows throws 0X0000138B instead of silently ignoring it. No duplicates allowed.
The root cause is almost always a script or configuration management tool (Ansible, Puppet, SCCM) that runs the same dependency command twice. Or you manually edited the registry and accidentally double-entered a service name. Either way, the solution is to clean up that list and remove the duplicate.
The Fix: Remove the Duplicate Dependency
I'll give you two methods. Use the PowerShell one unless you're stuck on a very old server. The registry method works everywhere but is riskier if you've never edited the registry.
Method 1: PowerShell (Recommended)
- Open PowerShell as Administrator.
- Identify your service name. Let's say it's
MyBackupSvc. - Run this command to see current dependencies:
Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\MyBackupSvc" -Name DependOnService
You'll see a list likeLanmanServer, RpcSs, LanmanServer— the duplicate is obvious. - Remove duplicates with this one-liner:
$deps = (Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\MyBackupSvc" -Name DependOnService).DependOnService $unique = $deps | Select-Object -Unique Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\MyBackupSvc" -Name DependOnService -Value $unique - Confirm the fix:
Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\MyBackupSvc" -Name DependOnService
Should show no duplicates. - Restart the service:
Restart-Service MyBackupSvc -Force
Method 2: Registry Editor (Legacy)
- Open Regedit as Administrator.
- Go to
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MyBackupSvc. - Double-click
DependOnServiceon the right pane. - You'll see each dependency on its own line. Delete any duplicate lines—one copy per service name. Don't remove the whole thing unless you want no dependencies.
- Click OK, close Regedit.
- Restart the service from services.msc or
net start MyBackupSvcfrom an admin command prompt.
When sc config Fails
If you try sc config MyBackupSvc depend= LanmanServer and still get the same error, it means the duplicate is already baked into the registry. The sc command won't overwrite duplicates—it just errors out. That's why you need to edit the registry or use PowerShell first. After that, sc config will work fine.
Still Broken? Check These
- Service name misspelled? If the dependency name doesn't match an existing service, Windows won't error on the
sc createbut it'll fail to start later. Verify withGet-Service. - Permissions issue? The account running the service might not have rights to start the dependency. Check the service logon account.
- Circular dependency? Service A depends on B and B depends on A? That's a different error (0X0000138C usually), but I've seen people confuse the two. Break the chain.
- Reboot needed? If you've edited the registry and the service still won't start, a reboot forces Windows to re-read the service tree. Annoying but reliable.
I know this error tripped me up the first time I saw it—I thought my script was broken. But once you understand it's just a duplicate check, it's a two-minute fix. You've got this.