private static LauncherArguments ProcessArguments() { var result = new LauncherArguments { // Default action is to run the server Actions = new List <LauncherArguments.ActionType> { LauncherArguments.ActionType.Run } }; // Environment.GetCommandLineArgs correctly process arguments regarding the presence of '\' and '"' var args = Environment.GetCommandLineArgs().Skip(1).ToArray(); foreach (var arg in args) { if (string.Equals(arg, "/Uninstall", StringComparison.InvariantCultureIgnoreCase)) { // No other action possible when uninstalling. result.Actions.Clear(); result.Actions.Add(LauncherArguments.ActionType.Uninstall); } else if (string.Equals(arg, "/UpdateTargets", StringComparison.InvariantCultureIgnoreCase)) { // UpdateTargets should be run first. result.Actions.Insert(0, LauncherArguments.ActionType.UpdateTargets); } } return(result); }
private static LauncherErrorCode ProcessAction(LauncherArguments args) { var result = LauncherErrorCode.UnknownError; foreach (var action in args.Actions) { switch (action) { case LauncherArguments.ActionType.Run: result = TryRun(); break; case LauncherArguments.ActionType.UpdateTargets: result = ForceUpdateTargets(); break; case LauncherArguments.ActionType.Uninstall: result = Uninstall(); break; default: // Unknown action return(LauncherErrorCode.UnknownError); } if (IsError(result)) { return(result); } } return(result); }