From 16205acbc8abcf613e7173109667f9a3e0e961f7 Mon Sep 17 00:00:00 2001 From: NextTurn <45985406+NextTurn@users.noreply.github.com> Date: Tue, 9 Jul 2019 00:00:00 +0800 Subject: [PATCH] Treat ERROR_SERVICE_ALREADY_RUNNING as success for start command --- src/Core/ServiceWrapper/Main.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Core/ServiceWrapper/Main.cs b/src/Core/ServiceWrapper/Main.cs index a47f3f4..192e548 100644 --- a/src/Core/ServiceWrapper/Main.cs +++ b/src/Core/ServiceWrapper/Main.cs @@ -718,7 +718,22 @@ namespace winsw if (s is null) ThrowNoSuchService(); - s.StartService(); + try + { + s.StartService(); + } + catch (WmiException e) + { + if (e.ErrorCode == ReturnValue.ServiceAlreadyRunning) + { + Log.Info($"The service with ID '{descriptor.Id}' has already been started"); + } + else + { + throw; + } + } + return; }