Portable Tool for an Ideal Windows Setup
C# activatorbloatware-removalcsharpdebloatdebloaterdisable-servicesmonitoring-systemportableprivacy-toolsregistry-tweakssystem-tuningsystem-utilitytelemetrytweakerwindows-10windows-11windows-debloatwindows-defenderwindows-optimizationwindows-tweaks
-fixed create restore points
Greedeks7a1c047e42db
diff --git a/.Source/GTweak/Languages/en/Localize.xaml b/.Source/GTweak/Languages/en/Localize.xamlindex f7203efd..e8231c1d 100644--- a/.Source/GTweak/Languages/en/Localize.xaml+++ b/.Source/GTweak/Languages/en/Localize.xaml@@ -44,7 +44,6 @@<v:String x:Key="createpoint_notification">It will take some time to create a recovery point</v:String><v:String x:Key="notsuccessfulpoint_notification">Something went wrong, it was not possible to create a restore point</v:String><v:String x:Key="successpoint_notification">The recovery point has been successfully created</v:String>- <v:String x:Key="readypoint_notification">The necessary point for recovery has already been created</v:String><v:String x:Key="notsuccessfulrecovery_notification">Something went wrong, recovery could not be started</v:String><v:String x:Key="readyactivate_notification">Your operating system does not need to be activated</v:String><v:String x:Key="activatewin_notification">The Windows activation process has started, it will take some time</v:String>diff --git a/.Source/GTweak/Languages/ru/Localize.xaml b/.Source/GTweak/Languages/ru/Localize.xamlindex 3f12d066..cd5587e4 100644--- a/.Source/GTweak/Languages/ru/Localize.xaml+++ b/.Source/GTweak/Languages/ru/Localize.xaml@@ -44,7 +44,6 @@<v:String x:Key="createpoint_notification">Cоздания точки восстановления займет некоторое время</v:String><v:String x:Key="notsuccessfulpoint_notification">Что-то пошло не так, не удалось создать точку восстановления</v:String><v:String x:Key="successpoint_notification">Точка восстановления успешно создана</v:String>- <v:String x:Key="readypoint_notification">Необходимая точка для восстановления уже создана</v:String><v:String x:Key="notsuccessfulrecovery_notification">Что-то пошло не так, не удалось запустить восстановления</v:String><v:String x:Key="readyactivate_notification">Ваша операционная система не нуждается в активации</v:String><v:String x:Key="activatewin_notification">Процесс активации Windows начался, это займет некоторое время</v:String>diff --git a/.Source/GTweak/Utilities/Tweaks/RecoveryPoint.cs b/.Source/GTweak/Utilities/Tweaks/RecoveryPoint.csindex b4cf922c..08aa9024 100644--- a/.Source/GTweak/Utilities/Tweaks/RecoveryPoint.cs+++ b/.Source/GTweak/Utilities/Tweaks/RecoveryPoint.cs@@ -16,17 +16,10 @@ namespace GTweak.Utilities.Tweaks[DllImport("srclient.dll")]private static extern int SRRemoveRestorePoint(int index);private static readonly ManagementClass RestorePoint = new ManagementClass(new ManagementScope(@"\\localhost\root\default"), new ManagementPath("SystemRestore"), new ObjectGetOptions());- private static ManagementBaseObject InParams;+ private static ManagementBaseObject InParams, OutParams;private static bool isWorkingCreatePoint = false;private static string output = string.Empty;- internal static async Task<bool> IsAlreadyPointAsync()- {- await StartPowerShellAsync(@"Get-ComputerRestorePoint | Where-Object {$_.Description -ne 'Точка созданная с помощью GTweak' -and $_.Description -ne 'A point created with a GTweak'} | Select-Object EventType | ft -hide");- return output.Contains("100");- }--private static void EnablePoint(){RegistryHelp.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\Policies\Microsoft\Windows NT\SystemRestore");@@ -65,12 +58,13 @@ namespace GTweak.Utilities.Tweaksif (isWorkingCreatePoint) return;isWorkingCreatePoint = true;+ RegistryHelp.Write(Registry.LocalMachine, @"SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore", "SystemRestorePointCreationFrequency", 0, RegistryValueKind.DWord);try{EnablePoint();- await StartPowerShellAsync(@"Get-ComputerRestorePoint | Where-Object {$_.Description -eq 'Точка созданная с помощью GTweak' -or $_.Description -eq 'A point created with a GTweak'} | Select-Object SequenceNumber | ft -hide");+ await StartPowerShellAsync(@"Get-ComputerRestorePoint | Where-Object {$_.Description -like '*GTweak*'} | Select-Object SequenceNumber | ft -hide");if (!string.IsNullOrEmpty(output))SRRemoveRestorePoint(Convert.ToInt32(output.Trim()));@@ -79,18 +73,17 @@ namespace GTweak.Utilities.TweaksInParams["Description"] = description;InParams["EventType"] = 100;InParams["RestorePointType"] = 12;- RestorePoint.InvokeMethod("CreateRestorePoint", InParams, null);+ OutParams = RestorePoint.InvokeMethod("CreateRestorePoint", InParams, null);- await Task.Delay(200);-- RestorePoint.Dispose();+ if ((uint)OutParams["ReturnValue"] == 0)+ new ViewNotification(300).Show("", "info", (string)Application.Current.Resources["successpoint_notification"]);+ else+ new ViewNotification(300).Show("", "warn", (string)Application.Current.Resources["notsuccessfulpoint_notification"]);isWorkingCreatePoint = false;-- new ViewNotification(300).Show("", "info", (string)Application.Current.Resources["successpoint_notification"]);+ RegistryHelp.DeleteValue(Registry.LocalMachine, @"SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore", "SystemRestorePointCreationFrequency");}catch { new ViewNotification(300).Show("", "warn", (string)Application.Current.Resources["notsuccessfulpoint_notification"]); }-}internal static void Run()diff --git a/.Source/GTweak/View/MoreView.xaml.cs b/.Source/GTweak/View/MoreView.xaml.csindex d406d5bd..da000dc2 100644--- a/.Source/GTweak/View/MoreView.xaml.cs+++ b/.Source/GTweak/View/MoreView.xaml.cs@@ -1,9 +1,8 @@using GTweak.Utilities;+using GTweak.Utilities.Helpers;using GTweak.Utilities.Tweaks;using System;-using System.ComponentModel;using System.Diagnostics;-using System.Threading.Tasks;using System.Windows.Controls;namespace GTweak.View@@ -28,18 +27,9 @@ namespace GTweak.Viewprivate async void BtnRestorePoint_ClickButton(object sender, EventArgs e){- if (await RecoveryPoint.IsAlreadyPointAsync() == false)- {- new ViewNotification().Show("", "info", (string)FindResource("createpoint_notification"));-- await Task.Delay(100);-- using BackgroundWorker backgroundWorker = new BackgroundWorker();- backgroundWorker.DoWork += delegate { RecoveryPoint.Create((string)FindResource("textpoint_more")); };- backgroundWorker.RunWorkerAsync();- }- else- new ViewNotification().Show("", "info", (string)FindResource("readypoint_notification"));+ new ViewNotification().Show("", "info", (string)FindResource("createpoint_notification"));+ BackgroundQueue backgroundQueue = new BackgroundQueue();+ await backgroundQueue.QueueTask(delegate { RecoveryPoint.Create((string)FindResource("textpoint_more")); });}private void BtnRecoveyLaunch_ClickButton(object sender, EventArgs e)@@ -50,20 +40,17 @@ namespace GTweak.Viewprivate void BtnClear_ClickButton(object sender, EventArgs e) => new ClearingMemory().StartMemoryCleanup();- private void BtnDisableRecovery_ClickButton(object sender, EventArgs e)+ private async void BtnDisableRecovery_ClickButton(object sender, EventArgs e){if (!RecoveryPoint.IsSystemRestoreDisabled()){- using BackgroundWorker backgroundWorker = new BackgroundWorker();- backgroundWorker.DoWork += delegate+ BackgroundQueue backgroundQueue = new BackgroundQueue();+ await backgroundQueue.QueueTask(delegate{try { RecoveryPoint.DisablePoint(); } catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }- };- backgroundWorker.RunWorkerCompleted += delegate- {- new ViewNotification(300).Show("", "info", (string)FindResource("disable_recovery_notification"));- };- backgroundWorker.RunWorkerAsync();+ });++ new ViewNotification(300).Show("", "info", (string)FindResource("disable_recovery_notification"));}elsenew ViewNotification().Show("", "info", (string)FindResource("warndisable_recovery_notification"));