Skip to content

ServiceManager.InstallServiceAsync: UpdateServiceConfig return value explicitly discarded #348

@Christophe-Rogiers

Description

@Christophe-Rogiers

Description

In src/Servy.Core/Services/ServiceManager.cs (line 462):

_ = UpdateServiceConfig(
    scmHandle: scmHandle,
    serviceName: options.ServiceName,
    description: options.Description,
    binPath: binPath,
    startType: options.StartType,
    username: lpServiceStartName,
    password: lpPassword,
    lpDependencies: lpDependencies,
    displayName: displayName
);

The _ = pattern explicitly discards the bool return value. While UpdateServiceConfig throws Win32Exception on some failures, the bool return indicates whether the underlying ChangeServiceConfig call succeeded. The install flow reports success even if the existing service's configuration was not actually updated.

Severity

Warning — install may report success when the service configuration update failed.

Suggested fix

Check the return value and handle the failure case:

bool updated = UpdateServiceConfig(...);
if (!updated)
{
    Logger.Warn("Failed to update existing service configuration.");
}

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions