fix(installer): check exit code (not stdout) for ERROR_SERVICE_ALREADY_RUNNING

This commit is contained in:
Mika Kuns
2026-04-15 09:32:26 +02:00
parent d87de152e0
commit 5b4af29420

View File

@@ -12,11 +12,11 @@ public sealed class StartServiceStep : IInstallStep
{ {
progress.Report($"Starting {ServiceName}..."); progress.Report($"Starting {ServiceName}...");
var (exit, output) = await ProcessRunner.RunAsync("sc.exe", $"start {ServiceName}", null, progress, ct); var (exit, _) = await ProcessRunner.RunAsync("sc.exe", $"start {ServiceName}", null, progress, ct);
if (exit == 0) return StepResult.Ok(); if (exit == 0) return StepResult.Ok();
// Exit 1056 = already running — that's fine too. // Exit 1056 = ERROR_SERVICE_ALREADY_RUNNING — that's fine too.
if (output.Contains("1056", StringComparison.OrdinalIgnoreCase)) if (exit == 1056)
{ {
progress.Report("Service was already running."); progress.Report("Service was already running.");
return StepResult.Ok(); return StepResult.Ok();