public static void StopService(this ServiceController sc) { if (sc.Status == ServiceControllerStatus.Stopped) { Console.WriteLine($"Service \"{sc.ServiceName}\" is already stopped"); return; } var startMsg = $"Stopping service \"{sc.ServiceName}\""; var timeoutMsg = $"Failed to stop the service, " + $"please refer to {Libs.GetCwd()}svc.log to see what happened"; var okMsg = $"Stopped Service \"{sc.ServiceName}\""; Libs.Timeout(sc.StopSvc, Consts.MAX_SERVICE_START_STOP_SECONDS, startMsg, timeoutMsg, okMsg); }