public sealed class WindowsServiceClient Explicit local or remote Service Control Manager access using the current Windows identity.
Remarks
Each call owns its native handles. Configuration and status reads are not an atomic snapshot.
Constructors
WindowsServiceClient
public WindowsServiceClient(string? machineName = null) Creates a client; null targets the local computer. Remote access uses Windows SCM RPC.
Methods
Continue
public void Continue(string name) Requests continuation of a paused service.
Create
public void Create(ServiceSpecification specification, string? password = null) Creates a new own-process service. Supplemental configuration is applied afterward and is not transactional.
Remarks
If a later step fails, the created service remains. Inspect its state before deciding how to recover. Password is never retained.
Delete
public bool Delete(string name) Marks an existing service for deletion. Returns false only if it was absent; deletion may be deferred by Windows.
Enumerate
public ImmutableArray<ServiceSummary> Enumerate() Enumerates Win32 services, including inactive services, without reading privileged configuration.
Find
public ServiceSnapshot? Find(string name) Reads service configuration and status; denied configuration access remains an error.
FindStatus
public ServiceStatus? FindStatus(string name) Reads status only; null means the service does not exist.
Pause
public void Pause(string name) Requests a pause.
Start
public void Start(string name) Starts a service. Already running is reported as a native conflict.
Stop
public void Stop(string name) Requests a stop; use WaitForStateAsync to observe completion.
Update
public void Update(string name, ServiceUpdate update, string? password = null) Updates only supplied fields. Password changes require an explicit AccountName. Native changes are not transactional.
WaitForStateAsync
public Task<ServiceStatus> WaitForStateAsync(string name, ServiceState state, TimeSpan timeout, CancellationToken cancellationToken = default) Waits for an observed state; timeout throws TimeoutException. Cancellation does not stop or undo service operations.