private static void StartGame(string applicationToLaunch, string arguments) { // Launch the application. var launcher = ApplicationLauncher.FromLocationAndArguments(applicationToLaunch, arguments); launcher.Start(); }
private static void StartGame(string applicationToLaunch, string arguments) { // Launch the application. var launcher = ApplicationLauncher.FromLocationAndArguments(applicationToLaunch, arguments); launcher.Start(); // Quit the process. Environment.Exit(0); }
/// <summary> /// Entry point for the application. /// </summary> public App() { PopulateCommandLineArgs(); /* Check if Kill Process */ if (_commandLineArguments.TryGetValue(Constants.ParameterKill, out string processId)) { var process = Process.GetProcessById(Convert.ToInt32(processId)); process.Kill(); ActionWrappers.SleepOnConditionWithTimeout(() => process.HasExited, 1000, 32); } /* Check if Launch Process */ if (_commandLineArguments.TryGetValue(Constants.ParameterLaunch, out string applicationToLaunch)) { // Acquire arguments _commandLineArguments.TryGetValue(Constants.ParameterArguments, out var arguments); if (arguments == null) { arguments = ""; } applicationToLaunch = Path.GetFullPath(applicationToLaunch); var application = ApplicationConfig.GetAllApplications().FirstOrDefault(x => Path.GetFullPath(x.Object.AppLocation) == applicationToLaunch); if (application != null) { arguments = $"{arguments} {application.Object.AppArguments}"; } // Launch the application. var launcher = ApplicationLauncher.FromLocationAndArguments(applicationToLaunch, arguments); launcher.Start(); // Quit the process. Environment.Exit(0); } // Move Contents involving UI elements to LoadCompleted this.Startup += OnStartup; }