Skip to content

Portable Tool for an Ideal Windows Setup

re & fix import for wd

Greedeksf73037cd9202
diff --git a/.Source/GTweak/Utilities/Managers/NotificationManager.cs b/.Source/GTweak/Utilities/Managers/NotificationManager.cs
index 0921fa78..7627e464 100644
--- a/.Source/GTweak/Utilities/Managers/NotificationManager.cs
+++ b/.Source/GTweak/Utilities/Managers/NotificationManager.cs
@@ -34,6 +34,7 @@ namespace GTweak.Utilities.Managers
{
new { Button = "TglButton2", Action = "logout" },
new { Button = "TglButton7", Action = "restart" },
+ new { Button = "TglButton8", Action = "restart" },
new { Button = "TglButton9", Action = "restart" },
new { Button = "TglButton10", Action = "restart" },
new { Button = "TglButton12", Action = "restart" },
diff --git a/.Source/GTweak/Utilities/Tweaks/DefenderManager/WindowsDefender.cs b/.Source/GTweak/Utilities/Tweaks/DefenderManager/WindowsDefender.cs
index 25317463..0668178e 100644
--- a/.Source/GTweak/Utilities/Tweaks/DefenderManager/WindowsDefender.cs
+++ b/.Source/GTweak/Utilities/Tweaks/DefenderManager/WindowsDefender.cs
@@ -11,7 +11,15 @@ namespace GTweak.Utilities.Tweaks.DefenderManager
{
internal class WindowsDefender : BackupRights
{
- internal static void Activate()
+ internal static void SetProtectionState(bool isDisabled)
+ {
+ if (isDisabled)
+ Deactivate();
+ else
+ Activate();
+ }
+
+ private static void Activate()
{
CommandExecutor.RunCommandAsTrustedInstaller("/c reg delete HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\AppHost /v EnableWebContentEvaluation /f & " +
"reg delete HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer /v SmartScreenEnabled /f & " +
@@ -161,7 +169,7 @@ namespace GTweak.Utilities.Tweaks.DefenderManager
ImportRights();
}
- internal static void Deactivate()
+ private static void Deactivate()
{
ExportRights();
diff --git a/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs b/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs
index b1e9f89b..b141a343 100644
--- a/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs
+++ b/.Source/GTweak/Utilities/Tweaks/SystemTweaks.cs
@@ -28,7 +28,6 @@ namespace GTweak.Utilities.Tweaks
internal sealed class SystemTweaks : Firewall
{
- internal static bool isTweakWorkingAntivirus = false;
private static bool _isNetshState = false, _isBluetoothStatus = false, _isTickState = false;
private readonly string _activeGuid = RegistryHelp.GetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes", "ActivePowerScheme", string.Empty);
@@ -92,8 +91,7 @@ namespace GTweak.Utilities.Tweaks
}
catch (Exception ex) { ErrorLogging.LogDebug(ex); }
- if (!isTweakWorkingAntivirus)
- systemV.TglButton8.StateNA = File.Exists(Path.Combine(PathLocator.Folders.SystemDrive, @"Windows\System32\smartscreen.exe"));
+ systemV.TglButton8.StateNA = File.Exists(Path.Combine(PathLocator.Folders.SystemDrive, @"Windows\System32\smartscreen.exe"));
systemV.TglButton9.StateNA =
RegistryHelp.CheckValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System", "PromptOnSecureDesktop", "0") ||
@@ -213,7 +211,7 @@ namespace GTweak.Utilities.Tweaks
[DllImport("user32.dll")]
private static extern bool SystemParametersInfo(uint _uiAction, uint _uiParam, uint[] _pvParam, uint _fWinIni);
- internal static async void ApplyTweaks(string tweak, bool isDisabled)
+ internal static async void ApplyTweaks(string tweak, bool isDisabled, bool canShowWindow = true)
{
INIManager.TempWrite(INIManager.TempTweaksSys, tweak, isDisabled);
@@ -273,20 +271,20 @@ namespace GTweak.Utilities.Tweaks
catch (Exception ex) { ErrorLogging.LogDebug(ex); }
break;
case "TglButton8":
+ if (canShowWindow)
{
WaitingWindow waitingWindow = new WaitingWindow();
waitingWindow.Show();
+
BackgroundQueue backgroundQueue = new BackgroundQueue();
- await backgroundQueue.QueueTask(delegate
- {
- if (isDisabled)
- WindowsDefender.Deactivate();
- else
- WindowsDefender.Activate();
- });
- await backgroundQueue.QueueTask(delegate { isTweakWorkingAntivirus = false; new NotificationManager(300).Show("restart"); });
+ await backgroundQueue.QueueTask(delegate { new NotificationManager().Show("", "info", "defender_notification"); });
+ await backgroundQueue.QueueTask(delegate { WindowsDefender.SetProtectionState(isDisabled); });
+ await backgroundQueue.QueueTask(delegate { new NotificationManager(300).Show("restart"); });
waitingWindow.Close();
}
+ else
+ WindowsDefender.SetProtectionState(isDisabled);
+
BlockWDefender(isDisabled);
break;
case "TglButton9":
diff --git a/.Source/GTweak/View/SystemView.xaml.cs b/.Source/GTweak/View/SystemView.xaml.cs
index 3b4c0e64..3eee9893 100644
--- a/.Source/GTweak/View/SystemView.xaml.cs
+++ b/.Source/GTweak/View/SystemView.xaml.cs
@@ -53,14 +53,7 @@ namespace GTweak.View
Parallel.Invoke(async delegate { await Task.Delay(1000); new SystemTweaks().AnalyzeAndUpdate(this); });
}
else
- {
- if (!SystemTweaks.isTweakWorkingAntivirus)
- {
- SystemTweaks.isTweakWorkingAntivirus = true;
- SystemTweaks.ApplyTweaks(toggleButton.Name, toggleButton.State);
- new NotificationManager().Show("", "info", "defender_notification");
- }
- }
+ SystemTweaks.ApplyTweaks(toggleButton.Name, toggleButton.State);
}
private void Page_Loaded(object sender, RoutedEventArgs e) => Parallel.Invoke(() => new SystemTweaks().AnalyzeAndUpdate(this));
diff --git a/.Source/GTweak/Windows/ImportWindow.xaml.cs b/.Source/GTweak/Windows/ImportWindow.xaml.cs
index 0b33355a..dbe84d3e 100644
--- a/.Source/GTweak/Windows/ImportWindow.xaml.cs
+++ b/.Source/GTweak/Windows/ImportWindow.xaml.cs
@@ -3,7 +3,6 @@ using GTweak.Utilities.Controls;
using GTweak.Utilities.Helpers;
using GTweak.Utilities.Managers;
using GTweak.Utilities.Tweaks;
-using GTweak.Utilities.Tweaks.DefenderManager;
using System;
using System.Collections.Generic;
using System.Diagnostics;
@@ -95,13 +94,7 @@ namespace GTweak.Windows
else if (tweak == "TglButton8")
{
BackgroundQueue backgroundQueue = new BackgroundQueue();
- await backgroundQueue.QueueTask(delegate
- {
- if (Convert.ToBoolean(value))
- WindowsDefender.Deactivate();
- else
- WindowsDefender.Activate();
- });
+ await backgroundQueue.QueueTask(delegate { SystemTweaks.ApplyTweaks(tweak, Convert.ToBoolean(value), false); });
}
else
SystemTweaks.ApplyTweaksSlider(tweak, Convert.ToUInt32(value));