Skip to content

Portable Tool for an Ideal Windows Setup

-changed tgl color & general class

Greedeks6c0a0c091b38
diff --git a/.Source/GTweak/GTweak.csproj b/.Source/GTweak/GTweak.csproj
index 46f0e9c0..7c40d7f7 100644
--- a/.Source/GTweak/GTweak.csproj
+++ b/.Source/GTweak/GTweak.csproj
@@ -280,15 +280,14 @@
<Compile Include="Utilities\Control\ViewNotification.cs" />
<Compile Include="Utilities\Helpers\TrustedInstaller.cs" />
<Compile Include="Utilities\Tweaks\ConfidentialityTweaks.cs" />
- <Compile Include="Utilities\Tweaks\Defragmentation.cs" />
<Compile Include="Utilities\Tweaks\Firewall.cs" />
<Compile Include="Utilities\Tweaks\InterfaceTweaks.cs" />
<Compile Include="Utilities\Tweaks\ServicesTweaks.cs" />
+ <Compile Include="Utilities\Tweaks\SystemMaintenance.cs" />
<Compile Include="Utilities\Tweaks\SystemTweaks.cs" />
<Compile Include="Utilities\Tweaks\UninstallingPakages.cs" />
<Compile Include="Utilities\Tweaks\WindowsDefender.cs" />
<Compile Include="Utilities\Tweaks\WindowsLicense.cs" />
- <Compile Include="Utilities\Tweaks\RecoveryPoint.cs" />
<Compile Include="Utilities\Helpers\TypewriterAnimation.cs" />
<Compile Include="Core\ViewModel\OtherContextVM.cs" />
<Compile Include="Windows\ImportWindow.xaml.cs">
diff --git a/.Source/GTweak/Styles/Themes/Dark/Colors.xaml b/.Source/GTweak/Styles/Themes/Dark/Colors.xaml
index 7d6d40d9..d9d9d44f 100644
--- a/.Source/GTweak/Styles/Themes/Dark/Colors.xaml
+++ b/.Source/GTweak/Styles/Themes/Dark/Colors.xaml
@@ -27,8 +27,8 @@
<Color x:Key="Color_Shadow">#1AFF7E</Color>
<Color x:Key="Color_Border_Gradient_1">#54FF9F</Color>
<Color x:Key="Color_Border_Gradient_2">#1AFF7E</Color>
- <Color x:Key="Color_ToggleButton_OFF_1">#505050</Color>
- <Color x:Key="Color_ToggleButton_OFF_2">#696969</Color>
+ <Color x:Key="Color_ToggleButton_OFF_1">#464646</Color>
+ <Color x:Key="Color_ToggleButton_OFF_2">#5C5C5C</Color>
<Color x:Key="Color_ToggleButton_ON_1">#54FF9F</Color>
<Color x:Key="Color_ToggleButton_ON_2">#24FF84</Color>
diff --git a/.Source/GTweak/Styles/Themes/Light/Colors.xaml b/.Source/GTweak/Styles/Themes/Light/Colors.xaml
index fe437e29..e4be3cd0 100644
--- a/.Source/GTweak/Styles/Themes/Light/Colors.xaml
+++ b/.Source/GTweak/Styles/Themes/Light/Colors.xaml
@@ -26,8 +26,8 @@
<Color x:Key="Color_Shadow">#13B65A</Color>
<Color x:Key="Color_Border_Gradient_1">#3CB671</Color>
<Color x:Key="Color_Border_Gradient_2">#13B65A</Color>
- <Color x:Key="Color_ToggleButton_OFF_1">#A8A8A8</Color>
- <Color x:Key="Color_ToggleButton_OFF_2">#B4B4B4</Color>
+ <Color x:Key="Color_ToggleButton_OFF_1">#949494</Color>
+ <Color x:Key="Color_ToggleButton_OFF_2">#9e9e9e</Color>
<Color x:Key="Color_ToggleButton_ON_1">#3CB671</Color>
<Color x:Key="Color_ToggleButton_ON_2">#1AB65E</Color>
diff --git a/.Source/GTweak/Utilities/Tweaks/Defragmentation.cs b/.Source/GTweak/Utilities/Tweaks/Defragmentation.cs
deleted file mode 100644
index 2cda3b48..00000000
--- a/.Source/GTweak/Utilities/Tweaks/Defragmentation.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-using GTweak.Utilities.Control;
-using GTweak.Utilities.Helpers;
-using Microsoft.Win32;
-using System.Windows;
-
-namespace GTweak.Utilities.Tweaks
-{
- internal sealed class Defragmentation : TaskSchedulerManager
- {
- private readonly string[] task = { @"Microsoft\Windows\Defrag\ScheduledDefrag" };
- internal void Disable()
- {
- if (IsTaskEnabled(task))
- {
- try
- {
- SetTaskStateOwner(task, false);
- RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\services\defragsvc", "Start", 4, RegistryValueKind.DWord);
- RegistryHelp.Write(Registry.LocalMachine, @"SOFTWARE\Microsoft\Dfrg\BootOptimizeFunction", "Enable", "N", RegistryValueKind.String);
-
- new ViewNotification(300).Show("", "info", (string)Application.Current.Resources["success_defrag_notification"]);
- }
- catch { new ViewNotification(300).Show("", "warn", (string)Application.Current.Resources["error_defrag_notification"]); }
- }
- else
- new ViewNotification(300).Show("", "info", (string)Application.Current.Resources["warn_defrag_notification"]);
- }
- }
-}
diff --git a/.Source/GTweak/Utilities/Tweaks/RecoveryPoint.cs b/.Source/GTweak/Utilities/Tweaks/SystemMaintenance.cs
similarity index 72%
rename from .Source/GTweak/Utilities/Tweaks/RecoveryPoint.cs
rename to .Source/GTweak/Utilities/Tweaks/SystemMaintenance.cs
index 3e861639..61c29684 100644
--- a/.Source/GTweak/Utilities/Tweaks/RecoveryPoint.cs
+++ b/.Source/GTweak/Utilities/Tweaks/SystemMaintenance.cs
@@ -10,7 +10,7 @@ using System.Windows;
namespace GTweak.Utilities.Tweaks
{
- internal sealed class RecoveryPoint
+ internal class SystemMaintenance : TaskSchedulerManager
{
[DllImport("srclient.dll")]
public static extern int DisableSR([MarshalAs(UnmanagedType.LPWStr)] string Drive);
@@ -20,41 +20,30 @@ namespace GTweak.Utilities.Tweaks
private static ManagementBaseObject InParams, OutParams;
private static bool isWorkingCreatePoint = false;
private static string output = string.Empty;
+ private static readonly string[] RestoreTask = { @"Microsoft\Windows\SystemRestore\SR" };
+ private readonly string[] DefragTask = { @"Microsoft\Windows\Defrag\ScheduledDefrag" };
- private static void EnablePoint()
- {
- RegistryHelp.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\Policies\Microsoft\Windows NT\SystemRestore");
+ internal static bool IsSystemRestoreDisabled => RegistryHelp.CheckValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore", "RPSessionInterval", "0");
- Microsoft.Win32.TaskScheduler.TaskService taskService = new Microsoft.Win32.TaskScheduler.TaskService();
- Microsoft.Win32.TaskScheduler.Task task = taskService.GetTask(@"Microsoft\Windows\SystemRestore\SR");
-
- if (task != null)
+ internal void DisableDefrag()
+ {
+ if (IsTaskEnabled(DefragTask))
{
- if (task.Enabled)
+ try
{
- task.Definition.Settings.Enabled = true;
- task.RegisterChanges();
+ SetTaskStateOwner(DefragTask, false);
+ RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\services\defragsvc", "Start", 4, RegistryValueKind.DWord);
+ RegistryHelp.Write(Registry.LocalMachine, @"SOFTWARE\Microsoft\Dfrg\BootOptimizeFunction", "Enable", "N", RegistryValueKind.String);
+
+ new ViewNotification(300).Show("", "info", (string)Application.Current.Resources["success_defrag_notification"]);
}
+ catch { new ViewNotification(300).Show("", "warn", (string)Application.Current.Resources["error_defrag_notification"]); }
}
-
- Process.Start(new ProcessStartInfo()
- {
- Arguments = "/c sc config wbengine start= demand && " +
- "reg add \"HKLM\\Software\\Microsoft\\Windows NT\\CurrentVersion\\SPP\\Clients\" /v \"{09F7EDC5 - 294E-4180 - AF6A - FB0E6A0E9513}\" /t REG_MULTI_SZ /d \"1\" /f &&" +
- "sc config swprv start= demand && sc config vds start= demand && sc config VSS start= demand",
- FileName = "cmd.exe",
- CreateNoWindow = true,
- WindowStyle = ProcessWindowStyle.Hidden
- });
-
- InParams = RestorePoint.GetMethodParameters("Enable");
- InParams["WaitTillEnabled"] = true;
- InParams["Drive"] = System.IO.Path.GetPathRoot(Environment.SystemDirectory);
- RestorePoint.InvokeMethod("Enable", InParams, null);
+ else
+ new ViewNotification(300).Show("", "info", (string)Application.Current.Resources["warn_defrag_notification"]);
}
-
- internal static async void Create(string description)
+ internal static async void CreateRestorePoint(string description)
{
if (isWorkingCreatePoint) return;
@@ -63,9 +52,9 @@ namespace GTweak.Utilities.Tweaks
try
{
- EnablePoint();
+ EnableRecovery();
- await StartPowerShellAsync(@"Get-ComputerRestorePoint | Where-Object {$_.Description -like '*GTweak*'} | Select-Object -ExpandProperty SequenceNumber");
+ await StartPowerShell(@"Get-ComputerRestorePoint | Where-Object {$_.Description -like '*GTweak*'} | Select-Object -ExpandProperty SequenceNumber");
if (!string.IsNullOrEmpty(output))
SRRemoveRestorePoint(Convert.ToInt32(output.Trim()));
@@ -87,9 +76,9 @@ namespace GTweak.Utilities.Tweaks
catch { new ViewNotification(300).Show("", "warn", (string)Application.Current.Resources["notsuccessfulpoint_notification"]); }
}
- internal static void Run()
+ internal static void StartRecovery()
{
- EnablePoint();
+ EnableRecovery();
Process.Start(new ProcessStartInfo()
{
@@ -100,32 +89,9 @@ namespace GTweak.Utilities.Tweaks
});
}
- internal static bool IsSystemRestoreDisabled()
+ internal static void DisableRestorePoint()
{
- try
- {
- return Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore", "RPSessionInterval", string.Empty).ToString() switch
- {
- "0" => true,
- _ => false
- };
- }
- catch { return false; }
- }
-
- internal static void DisablePoint()
- {
- Microsoft.Win32.TaskScheduler.TaskService taskService = new Microsoft.Win32.TaskScheduler.TaskService();
- Microsoft.Win32.TaskScheduler.Task task = taskService.GetTask(@"Microsoft\Windows\SystemRestore\SR");
-
- if (task != null)
- {
- if (task.Enabled)
- {
- task.Definition.Settings.Enabled = false;
- task.RegisterChanges();
- }
- }
+ SetTaskState(RestoreTask, false);
Process.Start(new ProcessStartInfo()
{
@@ -144,9 +110,31 @@ namespace GTweak.Utilities.Tweaks
DisableSR(UsePath.SystemDisk + @"\\");
}
- private static async Task<string> StartPowerShellAsync(string arguments)
+ private static void EnableRecovery()
+ {
+ RegistryHelp.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\Policies\Microsoft\Windows NT\SystemRestore");
+
+ SetTaskState(RestoreTask, true);
+
+ Process.Start(new ProcessStartInfo()
+ {
+ Arguments = "/c sc config wbengine start= demand && " +
+ "reg add \"HKLM\\Software\\Microsoft\\Windows NT\\CurrentVersion\\SPP\\Clients\" /v \"{09F7EDC5 - 294E-4180 - AF6A - FB0E6A0E9513}\" /t REG_MULTI_SZ /d \"1\" /f &&" +
+ "sc config swprv start= demand && sc config vds start= demand && sc config VSS start= demand",
+ FileName = "cmd.exe",
+ CreateNoWindow = true,
+ WindowStyle = ProcessWindowStyle.Hidden
+ });
+
+ InParams = RestorePoint.GetMethodParameters("Enable");
+ InParams["WaitTillEnabled"] = true;
+ InParams["Drive"] = System.IO.Path.GetPathRoot(Environment.SystemDirectory);
+ RestorePoint.InvokeMethod("Enable", InParams, null);
+ }
+
+ private static async Task<string> StartPowerShell(string arguments)
{
- var startInfo = new ProcessStartInfo
+ ProcessStartInfo startInfo = new ProcessStartInfo
{
FileName = "powershell.exe",
Arguments = arguments,
diff --git a/.Source/GTweak/View/MoreView.xaml.cs b/.Source/GTweak/View/MoreView.xaml.cs
index bfbb4425..de1bf925 100644
--- a/.Source/GTweak/View/MoreView.xaml.cs
+++ b/.Source/GTweak/View/MoreView.xaml.cs
@@ -29,27 +29,27 @@ namespace GTweak.View
{
new ViewNotification().Show("", "info", (string)FindResource("createpoint_notification"));
BackgroundQueue backgroundQueue = new BackgroundQueue();
- await backgroundQueue.QueueTask(delegate { RecoveryPoint.Create((string)FindResource("textpoint_more")); });
+ await backgroundQueue.QueueTask(delegate { SystemMaintenance.CreateRestorePoint((string)FindResource("textpoint_more")); });
}
private void BtnRecoveyLaunch_ClickButton(object sender, EventArgs e)
{
- try { RecoveryPoint.Run(); }
+ try { SystemMaintenance.StartRecovery(); }
catch { new ViewNotification().Show("", "warn", (string)FindResource("notsuccessfulrecovery_notification")); }
}
private void BtnClear_ClickButton(object sender, EventArgs e) => new ClearingMemory().StartMemoryCleanup();
- private void BtnDisableDefrag_ClickButton(object sender, EventArgs e) => new Defragmentation().Disable();
+ private void BtnDisableDefrag_ClickButton(object sender, EventArgs e) => new SystemMaintenance().DisableDefrag();
private async void BtnDisableRecovery_ClickButton(object sender, EventArgs e)
{
- if (!RecoveryPoint.IsSystemRestoreDisabled())
+ if (SystemMaintenance.IsSystemRestoreDisabled)
{
BackgroundQueue backgroundQueue = new BackgroundQueue();
await backgroundQueue.QueueTask(delegate
{
- try { RecoveryPoint.DisablePoint(); } catch (Exception ex) { Debug.WriteLine(ex.Message); }
+ try { SystemMaintenance.DisableRestorePoint(); } catch (Exception ex) { Debug.WriteLine(ex.Message); }
});
new ViewNotification(300).Show("", "info", (string)FindResource("disable_recovery_notification"));