Skip to content

[Correctness] ServiceManager.cs — InstallServiceAsync leaves partial service in SCM on post-create config failure #564

@Christophe-Rogiers

Description

@Christophe-Rogiers

Severity: Critical

File: src/Servy.Core/Services/ServiceManager.cs
Lines: 443–474

Description:
When CreateService succeeds but subsequent configuration calls fail (EnablePreShutdown returns false at line 445, or ChangeServiceConfig2 for delayed auto-start fails at line 463), the method returns OperationResult.Failure. The finally block closes the handle, but the newly created service is left in the SCM database in an incomplete state — no pre-shutdown timeout configured, or missing the delayed-start flag. The SCM shows it as installed but it will behave incorrectly.

Suggested fix:
On any post-create configuration failure, call _windowsServiceApi.DeleteService(serviceHandle) before returning the failure result to roll back the partial installation.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions