瀏覽代碼

Treat ERROR_SERVICE_ALREADY_RUNNING as success for start command

NextTurn 6 年之前
父節點
當前提交
16205acbc8
共有 1 個文件被更改,包括 16 次插入1 次删除
  1. 16 1
      src/Core/ServiceWrapper/Main.cs

+ 16 - 1
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;
             }