Пример #1
0
        public string GetJavaInSystem()
        {
            var javaVersion = string.Empty;

            try
            {
                var p = new Process
                {
                    StartInfo =
                    {
                        UseShellExecute        = false,
                        RedirectStandardOutput = true,
                        RedirectStandardError  = true,
                        CreateNoWindow         = true,
                        FileName  = "java",
                        Arguments = "-version"
                    }
                };
                _processAccessor.Start(p);
                javaVersion = _processAccessor.GetStandardError(p).ReadLine();
                _processAccessor.GetStandardError(p).ReadToEnd();
                _processAccessor.WaitForExit(p);
                Logger.LogDebug("Arma3SyncService", $"Java version in system detected: {javaVersion}");
            }
            catch (Exception e)
            {
                Logger.LogException("Arma3SyncService", "Error detecting Java version", e);
            }

            return(javaVersion);
        }
Пример #2
0
        /// <summary>
        /// Extract and execute external updater, then close the application
        /// </summary>
        private void RunUpdater()
        {
            Logger.LogDebug("UpdaterService", "Preparing to run updater");

            try
            {
                //Extract updater
                _fileAccessor.WriteAllBytes(ApplicationConfig.UpdaterPath, Properties.Resources._11thLauncher_Updater);

                var appPath     = Path.GetFullPath(Assembly.GetExecutingAssembly().Location);
                var downloadUrl = _release.assets.First().browser_download_url;
                var hashUrl     = _release.assets.ElementAt(1).browser_download_url;

                //Execute updater
                var p = new Process
                {
                    StartInfo =
                    {
                        FileName  = ApplicationConfig.UpdaterPath,
                        Arguments = string.Concat("\"",           appPath,"\" ", downloadUrl, " ", hashUrl)
                    }
                };
                _processAccessor.Start(p);
            }
            catch (Exception e)
            {
                Logger.LogException("UpdaterService", "Error trying to launch updater", e);
                return;
            }

            Logger.LogDebug("UpdaterService", "Updater started, shutting down...");

            Application.Current.Shutdown();
        }
Пример #3
0
        public LaunchGameResult StartGame()
        {
            var result       = LaunchGameResult.GameLaunched;
            var gameParams   = string.Join(" ", GetParameterArguments(), GetAddonArguments(), GetConnectionArguments()).Trim();
            var elevation    = RunningAsAdmin();
            var steamRunning = SteamRunning();

            Process process = new Process
            {
                StartInfo =
                {
                    FileName = GetGameExecutablePath(),
                    Verb     = RunningAsAdmin() ? "runas" : string.Empty
                }
            };

            if (gameParams.Length > 0)
            {
                process.StartInfo.Arguments = gameParams;
            }

            if (string.IsNullOrEmpty(process.StartInfo.FileName))
            {
                result = LaunchGameResult.UndefinedPath;
            }
            if (!elevation)
            {
                result = result | LaunchGameResult.NoElevation;
            }
            if (!steamRunning)
            {
                result = result | LaunchGameResult.NoSteam;
            }

            if (result == LaunchGameResult.GameLaunched)
            {
                try
                {
                    _processAccessor.Start(process);
                    Logger.LogInfo("GameService", $"Starting ArmA 3 in {LaunchSettings.Platform}");
                }
                catch (Exception e)
                {
                    result = LaunchGameResult.LaunchError;
                    Logger.LogException("GameService", "Error starting ArmA 3", e);
                }
            }
            else
            {
                Logger.LogInfo("GameService", $"Unable to launch game: {result}");
            }

            return(result);
        }