Exemplo n.º 1
0
        public void InstallUpdate()
        {
            var updateFilePath = Path.Combine(DownloadPath, UpdateFileName);
            var updateExists   = File.Exists(updateFilePath);

            if (!updateExists)
            {
                Log.Warning($"Cannot update, update file not found. {updateFilePath}");
                return;
            }

            var arguments = $"-o \"{ExecutablePath}\" -u \"{updateFilePath}\"";

            Log.Debug("Running updater");
            Log.Debug(arguments);

            var processStartInfo = new ProcessStartInfo
            {
                FileName        = UpdaterPath,
                Arguments       = arguments,
                UseShellExecute = true
            };

            if (!FileUtilities.HasWriteAccess(AppUtilities.ApplicationFilePath) && Environment.OSVersion.Version.Major >= 6)
            {
                Log.Information("Running updater as admin");
                processStartInfo.Verb = "runas";
            }

            Process.Start(processStartInfo);

            AppUtilities.ShutdownApplication();
        }