Skip to content

Portable Tool for an Ideal Windows Setup

-fix disabling WD & saving backup data about WD parameters.

Greedeksf2fa9b74f93a
diff --git a/.Source/GTweak/Utilities/Helpers/CommandExecutor.cs b/.Source/GTweak/Utilities/Helpers/CommandExecutor.cs
index 4bf2a0b5..269b411b 100644
--- a/.Source/GTweak/Utilities/Helpers/CommandExecutor.cs
+++ b/.Source/GTweak/Utilities/Helpers/CommandExecutor.cs
@@ -14,6 +14,7 @@ namespace GTweak.Utilities.Helpers
{
FileName = isPowerShell ? "powershell.exe" : "cmd.exe",
Arguments = isPowerShell ? $"-NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -Command \"{arguments}\"" : arguments,
+ Verb = "runas",
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
@@ -46,6 +47,7 @@ namespace GTweak.Utilities.Helpers
{
FileName = isPowerShell ? "powershell.exe" : "cmd.exe",
Arguments = isPowerShell ? $"-NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -Command \"{arguments}\"" : arguments,
+ Verb = "runas",
WindowStyle = ProcessWindowStyle.Hidden,
CreateNoWindow = true,
});
diff --git a/.Source/GTweak/Utilities/Helpers/TakingOwnership.cs b/.Source/GTweak/Utilities/Helpers/TakingOwnership.cs
index 0bbc4b79..77c6b3e9 100644
--- a/.Source/GTweak/Utilities/Helpers/TakingOwnership.cs
+++ b/.Source/GTweak/Utilities/Helpers/TakingOwnership.cs
@@ -1,4 +1,5 @@
using System;
+using System.Diagnostics;
using System.Runtime.InteropServices;
namespace GTweak.Utilities.Helpers
@@ -104,6 +105,7 @@ namespace GTweak.Utilities.Helpers
DENY_ACCESS
}
+ private const string SE_DEBUG_NAME = "SeDebugPrivilege";
private const string SE_TAKE_OWNERSHIP_NAME = "SeTakeOwnershipPrivilege";
private static SID_IDENTIFIER_AUTHORITY SECURITY_NT_AUTHORITY =
new SID_IDENTIFIER_AUTHORITY() { Value = new byte[] { 0, 0, 0, 0, 0, 5 } };
@@ -182,6 +184,23 @@ namespace GTweak.Utilities.Helpers
IntPtr OldAcl,
ref IntPtr NewAcl);
+ internal static bool GrantDebugPrivilege()
+ {
+ if (!OpenProcessToken(Process.GetCurrentProcess().Handle, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, out IntPtr hToken))
+ return false;
+
+ if (!LookupPrivilegeValueA(null, SE_DEBUG_NAME, out LUID luid))
+ return false;
+
+ TOKEN_PRIVILEGES tp;
+ tp.PrivilegeCount = 1;
+ tp.Privileges = new LUID_AND_ATTRIBUTES[1];
+ tp.Privileges[0].Luid = luid;
+ tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
+
+ return AdjustTokenPrivileges(hToken, false, ref tp, 0, IntPtr.Zero, IntPtr.Zero);
+ }
+
internal static void GrantAdministratorsAccess(string name, SE_OBJECT_TYPE type)
{
SID_IDENTIFIER_AUTHORITY sidNTAuthority = SECURITY_NT_AUTHORITY;
diff --git a/.Source/GTweak/Utilities/Tweaks/DefenderManager/BackupRights.cs b/.Source/GTweak/Utilities/Tweaks/DefenderManager/BackupRights.cs
index 2323226e..bb450933 100644
--- a/.Source/GTweak/Utilities/Tweaks/DefenderManager/BackupRights.cs
+++ b/.Source/GTweak/Utilities/Tweaks/DefenderManager/BackupRights.cs
@@ -12,8 +12,9 @@ namespace GTweak.Utilities.Tweaks.DefenderManager
{
internal class BackupRights : TaskSchedulerManager
{
- private static readonly string jsonFilePath = Path.Combine(StoragePaths.SystemDisk, @"Windows\System32\Config", "WD_Backup_GTweak.json");
- private static readonly string aclFilePath = Path.Combine(StoragePaths.SystemDisk, @"Windows\System32\Config", "WD_Backup_GTweak.acl");
+ private static readonly string folderBackupPath = Path.Combine(StoragePaths.SystemDisk, @"Windows\System32\Config\WDBackup_GTweak");
+ private static readonly string jsonFilePath = Path.Combine(folderBackupPath, "BackupData.json");
+ private static readonly string aclFilePath = Path.Combine(folderBackupPath, "BackupRights.acl");
private static readonly Dictionary<string, RegistryKey> StorageRegPaths = new Dictionary<string, RegistryKey>
{
@@ -36,48 +37,50 @@ namespace GTweak.Utilities.Tweaks.DefenderManager
{ @"SOFTWARE\Policies\Microsoft\Microsoft Antimalware", Registry.LocalMachine },
{ @"SOFTWARE\Policies\Microsoft\Windows Defender\Signature Updates", Registry.LocalMachine },
{ @"SOFTWARE\Microsoft\Security Center", Registry.LocalMachine },
+ { @"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\smartscreen.exe", Registry.LocalMachine },
+ { @"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\MsMpEng.exe", Registry.LocalMachine },
+ { @"Software\Microsoft\Edge", Registry.CurrentUser },
};
-
internal static void ExportRights()
{
- try
+ if (Directory.Exists(folderBackupPath) == false)
{
- if (File.Exists(jsonFilePath) && File.Exists(aclFilePath))
+ try
{
- File.Delete(jsonFilePath);
- File.Delete(aclFilePath);
- }
+ Directory.CreateDirectory(folderBackupPath);
- var allValues = new Dictionary<string, Dictionary<string, object>>();
- var aclDataDict = new Dictionary<string, string>();
+ var allValues = new Dictionary<string, Dictionary<string, object>>();
+ var aclDataDict = new Dictionary<string, string>();
- foreach (var entry in StorageRegPaths)
- {
- string path = entry.Key;
- RegistryKey baseKey = entry.Value;
+ foreach (var entry in StorageRegPaths)
+ {
+ string path = entry.Key;
+ RegistryKey baseKey = entry.Value;
- using RegistryKey key = baseKey.OpenSubKey(path, false);
- if (key == null)
- continue;
+ using RegistryKey key = baseKey.OpenSubKey(path, false);
+ if (key == null)
+ continue;
- var values = new Dictionary<string, object>();
- foreach (string valueName in key.GetValueNames())
- values[valueName] = key.GetValue(valueName);
+ var values = new Dictionary<string, object>();
+ foreach (string valueName in key.GetValueNames())
+ values[valueName] = key.GetValue(valueName);
- allValues[path] = values;
+ allValues[path] = values;
- RegistrySecurity security = key.GetAccessControl();
- string aclData = security.GetSecurityDescriptorSddlForm(AccessControlSections.All);
- aclDataDict[path] = aclData;
- }
+ RegistrySecurity security = key.GetAccessControl();
+ string aclData = security.GetSecurityDescriptorSddlForm(AccessControlSections.All);
+ aclDataDict[path] = aclData;
+ }
- File.WriteAllText(jsonFilePath, JsonConvert.SerializeObject(allValues, Formatting.Indented));
- File.WriteAllText(aclFilePath, JsonConvert.SerializeObject(aclDataDict, Formatting.Indented));
+ File.WriteAllText(jsonFilePath, JsonConvert.SerializeObject(allValues, Formatting.Indented));
+ File.WriteAllText(aclFilePath, JsonConvert.SerializeObject(aclDataDict, Formatting.Indented));
+ }
+ catch (Exception ex) { Debug.WriteLine(ex.Message); }
}
- catch (Exception ex) { Debug.WriteLine(ex.Message); }
}
+
internal static void ImportRights()
{
if (File.Exists(jsonFilePath) && File.Exists(aclFilePath))
diff --git a/.Source/GTweak/Utilities/Tweaks/DefenderManager/WindowsDefender.cs b/.Source/GTweak/Utilities/Tweaks/DefenderManager/WindowsDefender.cs
index de96974a..f16095e3 100644
--- a/.Source/GTweak/Utilities/Tweaks/DefenderManager/WindowsDefender.cs
+++ b/.Source/GTweak/Utilities/Tweaks/DefenderManager/WindowsDefender.cs
@@ -6,6 +6,7 @@ using System;
using System.Diagnostics;
using System.IO;
using System.Text;
+using System.Threading.Tasks;
namespace GTweak.Utilities.Tweaks.DefenderManager
{
@@ -57,13 +58,17 @@ namespace GTweak.Utilities.Tweaks.DefenderManager
"reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\SecurityHealthService /t REG_DWORD /v Start /d 2 /f &" +
"reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\WinDefend /t REG_DWORD /v Start /d 2 /f & " +
"reg delete HKLM\\SYSTEM\\CurrentControlSet\\Services\\WinDefend /t REG_DWORD /v AutorunsDisabled /f & " +
- "reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\WdNisSvc /t REG_DWORD /v Start /d 3 /f");
-
- TrustedInstaller.CreateProcessAsTrustedInstaller(SettingsRepository.PID, $"{Path.Combine(Environment.SystemDirectory, "WindowsPowerShell\\v1.0\\powershell.exe")} -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -Command \"Rename-Item -Path '{Path.Combine(StoragePaths.SystemDisk, @"Windows\System32\BlockSS.exe")}' -NewName 'smartscreen.exe'\"");
- TrustedInstaller.CreateProcessAsTrustedInstaller(SettingsRepository.PID, $"{Path.Combine(Environment.SystemDirectory, "WindowsPowerShell\\v1.0\\powershell.exe")} -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -Command \"Rename-Item -Path '{Path.Combine(StoragePaths.SystemDisk, @"Program Files\Windows Defender\BlockAntimalware.exe")}' -NewName 'MsMpEng.exe'\"");
- TrustedInstaller.CreateProcessAsTrustedInstaller(SettingsRepository.PID, $"{Path.Combine(Environment.SystemDirectory, "WindowsPowerShell\\v1.0\\powershell.exe")} -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -Command \"Rename-Item -Path '{Path.Combine(StoragePaths.SystemDisk, @"Program Files\Windows Defender\BlockAntimalwareCore.exe")}' -NewName 'MpDefenderCoreService.exe'\"");
- TrustedInstaller.CreateProcessAsTrustedInstaller(SettingsRepository.PID, $"{Path.Combine(Environment.SystemDirectory, "WindowsPowerShell\\v1.0\\powershell.exe")} -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -Command \"Get-ChildItem -Path '{Path.Combine(StoragePaths.SystemDisk, @"ProgramData\Microsoft\Windows Defender\Platform\*")}' -Directory | ForEach-Object {{ if (Test-Path -Path \"$_\\BlockAntimalware.exe\") {{ Rename-Item -Path \"$_\\BlockAntimalware.exe\" -NewName 'MsMpEng.exe' }} }}\"");
- TrustedInstaller.CreateProcessAsTrustedInstaller(SettingsRepository.PID, $"{Path.Combine(Environment.SystemDirectory, "WindowsPowerShell\\v1.0\\powershell.exe")} -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -Command \"Get-ChildItem -Path '{Path.Combine(StoragePaths.SystemDisk, @"ProgramData\Microsoft\Windows Defender\Platform\*")}' -Directory | ForEach-Object {{ if (Test-Path -Path \"$_\\BlockAntimalwareCore.exe\") {{ Rename-Item -Path \"$_\\BlockAntimalwareCore.exe\" -NewName 'MpDefenderCoreService.exe' }} }}\"");
+ "reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\WdNisSvc /t REG_DWORD /v Start /d 3 /f & " +
+ "reg add \"HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Image File Execution Options\\MsMpEng.exe\" /t REG_DWORD /v CFGOptions /d 1 /f & " +
+ "reg delete \"HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Image File Execution Options\\MsMpEng.exe\" /v Debugger /f & " +
+ "reg add \"HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Image File Execution Options\\smartscreen.exe\" /t REG_DWORD /v CFGOptions /d 1 /f & " +
+ "reg delete \"HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Image File Execution Options\\smartscreen.exe\" /v Debugger /f");
+
+ TrustedInstaller.CreateProcessAsTrustedInstaller(SettingsRepository.PID, $"cmd.exe /c \"rename \"" + Path.Combine(StoragePaths.SystemDisk, @"Windows\System32\BlockSS.exe") + "\" smartscreen.exe\"");
+ TrustedInstaller.CreateProcessAsTrustedInstaller(SettingsRepository.PID, $"cmd.exe /c \"rename \"" + Path.Combine(StoragePaths.SystemDisk, @"Program Files\Windows Defender\BlockAntimalware.exe") + "\" MsMpEng.exe\"");
+ TrustedInstaller.CreateProcessAsTrustedInstaller(SettingsRepository.PID, $"cmd.exe /c \"rename \"" + Path.Combine(StoragePaths.SystemDisk, @"Program Files\Windows Defender\BlockAntimalwareCore.exe") + "\" MpDefenderCoreService.exe\"");
+ TrustedInstaller.CreateProcessAsTrustedInstaller(SettingsRepository.PID, $"cmd.exe /c for /d %D in (\"{Path.Combine(StoragePaths.SystemDisk, @"ProgramData\Microsoft\Windows Defender\Platform\*")}\") do if exist \"%D\\BlockAntimalware.exe\" ren \"%D\\BlockAntimalware.exe\" MsMpEng.exe");
+ TrustedInstaller.CreateProcessAsTrustedInstaller(SettingsRepository.PID, $"cmd.exe /c for /d %D in (\"{Path.Combine(StoragePaths.SystemDisk, @"ProgramData\Microsoft\Windows Defender\Platform\*")}\") do if exist \"%D\\BlockAntimalwareCore.exe\" ren \"%D\\BlockAntimalwareCore.exe\" MpDefenderCoreService.exe");
RunCmdCommand("sc start WinDefend");
RunPowerShellCommand("Start-Service -Name WinDefend; Set-Service -Name WinDefend -StartupType Automatic");
@@ -144,10 +149,13 @@ namespace GTweak.Utilities.Tweaks.DefenderManager
RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\WdFilter", "Start", "0", RegistryValueKind.DWord, true);
RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\WdBoot", "Start", "0", RegistryValueKind.DWord, true);
RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\WdNisDrv", "Start", "3", RegistryValueKind.DWord, true);
- RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\MDCoreSvc", "Start", "3", RegistryValueKind.DWord);
+ RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\MDCoreSvc", "Start", "3", RegistryValueKind.DWord, true);
+
+ RegistryHelp.Write(Registry.LocalMachine, @"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\MsMpEng.exe", "CFGOptions", 1, RegistryValueKind.DWord);
+ RegistryHelp.Write(Registry.LocalMachine, @"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\smartscreen.exe", "CFGOptions", 1, RegistryValueKind.DWord);
SetTaskState(true, WinDefenderTasks);
- KillProcess("SecHealthUI");
+ KillProcess(new string[] { "SecurityHealthService", "SecurityHealthService" });
RunPowerShellCommand(@"Get-AppXpackage Microsoft.WindowsDefender | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register ""$($_.InstallLocation)\AppXManifest.xml""}");
RegistryHelp.Write(Registry.ClassesRoot, @"*\shellex\ContextMenuHandlers\EPP", "", "{09A47860-11B0-4DA5-AFA5-26D86198A780}", RegistryValueKind.String);
@@ -159,10 +167,9 @@ namespace GTweak.Utilities.Tweaks.DefenderManager
ImportRights();
}
- internal void Disable()
+ internal async void Disable()
{
- KillProcess("smartscreen");
- KillProcess("MsMpEng");
+ KillProcess(new string[] { "smartscreen", "MpDefenderCoreService", "MsMpEng" });
ExportRights();
@@ -302,7 +309,7 @@ namespace GTweak.Utilities.Tweaks.DefenderManager
RegistryHelp.DeleteValue(Registry.CurrentUser, @"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "Windows Defender");
RegistryHelp.DeleteValue(Registry.LocalMachine, @"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "SecurityHealth");
- KillProcess("SecHealthUI");
+ KillProcess(new string[] { "SecurityHealthService", "SecurityHealthService" });
TrustedInstaller.CreateProcessAsTrustedInstaller(SettingsRepository.PID, "cmd.exe /c taskkill /f /im MsMpEng.exe & reg add HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\AppHost /t REG_DWORD /v EnableWebContentEvaluation /d 0 /f & " +
"reg add HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer /t REG_SZ /v SmartScreenEnabled /d \"off\" /f & " +
@@ -332,7 +339,14 @@ namespace GTweak.Utilities.Tweaks.DefenderManager
"reg add \"HKLM\\SOFTWARE\\Policies\\Microsoft\\Windows Defender\\SmartScreen\" /t REG_DWORD /v ConfigureAppInstallControlEnabled /d 0 /f & " +
"reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\WinDefend /t REG_DWORD /v Start /d 4 /f & " +
"reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\WinDefend /t REG_DWORD /v AutorunsDisabled / d 3 /f & " +
- "reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\WdNisSvc /t REG_DWORD /v Start /d 4 /f");
+ "reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\WdNisSvc /t REG_DWORD /v Start /d 4 /f & " +
+ "reg add \"HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Image File Execution Options\\MsMpEng.exe\" /t REG_DWORD /v CFGOptions /d 0 /f & " +
+ "reg add \"HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Image File Execution Options\\MsMpEng.exe\" /t REG_SZ /v Debugger /d \"\" /f & " +
+ "reg add \"HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Image File Execution Options\\smartscreen.exe\" /t REG_DWORD /v CFGOptions /d 0 /f & " +
+ "reg add \"HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Image File Execution Options\\smartscreen.exe\" /t REG_SZ /v Debugger /d \"\" /f");
+
+ RunCmdCommand("sc config WinDefend start= disabled");
+ RunPowerShellCommand("Stop-Service -Name WinDefend; Set-Service -Name WinDefend -StartupType Disabled");
RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\WinDefend", "Start", "4", RegistryValueKind.DWord, true);
RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\WinDefend", "AutorunsDisabled", "3", RegistryValueKind.DWord);
@@ -343,28 +357,36 @@ namespace GTweak.Utilities.Tweaks.DefenderManager
RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\WdFilter", "Start", "4", RegistryValueKind.DWord, true);
RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\WdBoot", "Start", "4", RegistryValueKind.DWord, true);
RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\WdNisDrv", "Start", "4", RegistryValueKind.DWord, true);
- RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\MDCoreSvc", "Start", "4", RegistryValueKind.DWord);
-
- RunCmdCommand("sc config WinDefend start= disabled");
- RunPowerShellCommand("Stop-Service -Name WinDefend; Set-Service -Name WinDefend -StartupType Disabled");
+ RegistryHelp.Write(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\MDCoreSvc", "Start", "4", RegistryValueKind.DWord, true);
RegistryHelp.DeleteFolderTree(Registry.ClassesRoot, @"*\shellex\ContextMenuHandlers\EPP");
RegistryHelp.DeleteFolderTree(Registry.ClassesRoot, @"Directory\shellex\ContextMenuHandlers\EPP");
RegistryHelp.DeleteFolderTree(Registry.ClassesRoot, @"Drive\shellex\ContextMenuHandlers\EPP");
RegistryHelp.DeleteFolderTree(Registry.ClassesRoot, @"CLSID\{09A47860-11B0-4DA5-AFA5-26D86198A780}\InprocServer32");
- KillProcess("smartscreen");
- KillProcess("MpDefenderCoreService");
- KillProcess("MsMpEng");
+ KillProcess(new string[] { "smartscreen", "MpDefenderCoreService", "MsMpEng", "SecurityHealthService", "SecurityHealthService", "wuauserv", "SearchUI", "RuntimeBroker" });
+
+ await Task.Delay(5000);
- TrustedInstaller.CreateProcessAsTrustedInstaller(SettingsRepository.PID, $"{Path.Combine(Environment.SystemDirectory, "WindowsPowerShell\\v1.0\\powershell.exe")} -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -Command \"Rename-Item -Path '{Path.Combine(StoragePaths.SystemDisk, @"Windows\System32\smartscreen.exe")}' -NewName 'BlockSS.exe'\"");
- TrustedInstaller.CreateProcessAsTrustedInstaller(SettingsRepository.PID, $"{Path.Combine(Environment.SystemDirectory, "WindowsPowerShell\\v1.0\\powershell.exe")} -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -Command \"Rename-Item -Path '{Path.Combine(StoragePaths.SystemDisk, @"Program Files\Windows Defender\MsMpEng.exe")}' -NewName 'BlockAntimalware.exe'\"");
- TrustedInstaller.CreateProcessAsTrustedInstaller(SettingsRepository.PID, $"{Path.Combine(Environment.SystemDirectory, "WindowsPowerShell\\v1.0\\powershell.exe")} -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -Command \"Rename-Item -Path '{Path.Combine(StoragePaths.SystemDisk, @"Program Files\Windows Defender\MpDefenderCoreService.exe")}' -NewName 'BlockAntimalwareCore.exe'\"");
- TrustedInstaller.CreateProcessAsTrustedInstaller(SettingsRepository.PID, $"{Path.Combine(Environment.SystemDirectory, "WindowsPowerShell\\v1.0\\powershell.exe")} -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -Command \"Get-ChildItem -Path '{Path.Combine(StoragePaths.SystemDisk, @"ProgramData\Microsoft\Windows Defender\Platform\*")}' -Directory | ForEach-Object {{ if (Test-Path -Path \"$_\\MsMpEng.exe\") {{ Rename-Item -Path \"$_\\MsMpEng.exe\" -NewName 'BlockAntimalware.exe' }} }}\"");
- TrustedInstaller.CreateProcessAsTrustedInstaller(SettingsRepository.PID, $"{Path.Combine(Environment.SystemDirectory, "WindowsPowerShell\\v1.0\\powershell.exe")} -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -Command \"Get-ChildItem -Path '{Path.Combine(StoragePaths.SystemDisk, @"ProgramData\Microsoft\Windows Defender\Platform\*")}' -Directory | ForEach-Object {{ if (Test-Path -Path \"$_\\MpDefenderCoreService.exe\") {{ Rename-Item -Path \"$_\\MpDefenderCoreService.exe\" -NewName 'BlockAntimalwareCore.exe' }} }}\"");
+ TrustedInstaller.CreateProcessAsTrustedInstaller(SettingsRepository.PID, $"cmd.exe /c \"rename \"" + Path.Combine(StoragePaths.SystemDisk, @"Windows\System32\smartscreen.exe") + "\" BlockSS.exe\"");
+ TrustedInstaller.CreateProcessAsTrustedInstaller(SettingsRepository.PID, $"cmd.exe /c \"rename \"" + Path.Combine(StoragePaths.SystemDisk, @"Program Files\Windows Defender\MsMpEng.exe") + "\" BlockAntimalware.exe\"");
+ TrustedInstaller.CreateProcessAsTrustedInstaller(SettingsRepository.PID, $"cmd.exe /c for /d %D in (\"{Path.Combine(StoragePaths.SystemDisk, @"ProgramData\Microsoft\Windows Defender\Platform\*")}\") do if exist \"%D\\MsMpEng.exe\" ren \"%D\\MsMpEng.exe\" BlockAntimalware.exe");
+ TrustedInstaller.CreateProcessAsTrustedInstaller(SettingsRepository.PID, $"cmd.exe /c \"rename \"" + Path.Combine(StoragePaths.SystemDisk, @"Program Files\Windows Defender\MpDefenderCoreService.exe") + "\" BlockAntimalwareCore.exe\"");
+ TrustedInstaller.CreateProcessAsTrustedInstaller(SettingsRepository.PID, $"cmd.exe /c for /d %D in (\"{Path.Combine(StoragePaths.SystemDisk, @"ProgramData\Microsoft\Windows Defender\Platform\*")}\") do if exist \"%D\\MpDefenderCoreService.exe\" ren \"%D\\MpDefenderCoreService.exe\" BlockAntimalwareCore.exe");
}
- private void KillProcess(string name) => TrustedInstaller.CreateProcessAsTrustedInstaller(SettingsRepository.PID, $"{Path.Combine(Environment.SystemDirectory, "WindowsPowerShell\\v1.0\\powershell.exe")} -NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -Command \"Stop-Process -Name {name} -Force\"");
+ private async void KillProcess(params string[] nameList)
+ {
+ TakingOwnership.GrantDebugPrivilege();
+ foreach (string getName in nameList)
+ {
+ foreach (Process process in Process.GetProcessesByName(getName))
+ {
+ try { process.Kill(); await Task.Delay(1000); }
+ catch (Exception ex) { Debug.WriteLine(ex.Message); }
+ }
+ }
+ }
private void RunPowerShellCommand(string command)
{
diff --git a/.Source/GTweak/Utilities/Tweaks/UninstallingPakages.cs b/.Source/GTweak/Utilities/Tweaks/UninstallingPakages.cs
index 762edb05..8173446b 100644
--- a/.Source/GTweak/Utilities/Tweaks/UninstallingPakages.cs
+++ b/.Source/GTweak/Utilities/Tweaks/UninstallingPakages.cs
@@ -261,12 +261,14 @@ namespace GTweak.Utilities.Tweaks
RegistryHelp.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\Classes\MSEdgeHTM", true);
RegistryHelp.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\Clients\StartMenuInternet\Microsoft Edge", true);
RegistryHelp.DeleteFolderTree(Registry.ClassesRoot, @"AppID\MicrosoftEdgeUpdate.exe", true);
+ RegistryHelp.DeleteFolderTree(Registry.CurrentUser, @"Software\Microsoft\EdgeUpdate", true);
if (removeWebViewFlag)
{
RegistryHelp.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\WOW6432Node\Microsoft\EdgeWebView", true);
RegistryHelp.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\Microsoft\EdgeWebView", true);
RegistryHelp.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft EdgeWebView", true);
+ RegistryHelp.DeleteFolderTree(Registry.CurrentUser, @"Software\Microsoft\EdgeWebView", true);
}
foreach (string folder in new string[] { "Edge", "EdgeCore", "EdgeUpdate", "Temp", "EdgeWebView" })