Result <ExpectedResults> ExecuteScAndGetResult(string args) { var scExe = ServiceControllerName; var sb = new StringBuilder(); var proceesExitCode = _processRunner.LaunchProcessWithoutShellExecuteAndWaitExitCode(scExe, args, s => sb.AppendLine(scExe + " Output:" + s), s => sb.AppendLine(scExe + " Error:" + s)); if (!Enum.IsDefined(typeof(ExpectedResults), proceesExitCode)) { throw new ServiceControllerWrapperException($"Command {scExe} returned unexpected exit code:{proceesExitCode}. Process output:{sb}"); } var knownExitCode = (ExpectedResults)proceesExitCode; return(Result.Ok(knownExitCode)); }