Skip to content

Portable Tool for an Ideal Windows Setup

refactor appx post removal logic into separate methods & centralize target paths

Greedeksea0d186ee3c9
diff --git a/.Source/GTweak/Modules/Common/PathTargets.cs b/.Source/GTweak/Modules/Common/PathTargets.cs
index 8ee0708a..98ceb71a 100644
--- a/.Source/GTweak/Modules/Common/PathTargets.cs
+++ b/.Source/GTweak/Modules/Common/PathTargets.cs
@@ -75,9 +75,11 @@ namespace GTweak.Modules.Common
internal static readonly string WallpaperCache = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Microsoft", "Windows", "Themes");
+ internal static readonly string OneDrive = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Microsoft", "OneDrive");
+
internal static readonly string Edge = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), "Microsoft", "Edge");
- internal static readonly string OneDrive = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Microsoft", "OneDrive");
+ internal static readonly string[] EdgeComponents = Array.ConvertAll(new[] { "Edge", "EdgeCore", "EdgeUpdate", "Temp", "EdgeWebView" }, name => Path.Combine(Path.GetDirectoryName(Edge)!, name));
}
internal static class Executable
@@ -301,10 +303,36 @@ namespace GTweak.Modules.Common
internal static readonly string OneDriveSetup = FindExecutablePath("onedrivesetup.exe");
- internal static readonly string[] OneDrive = new[]
+ internal static string EdgeSetup
+ {
+ get
+ {
+ string root = Path.Combine(Folders.Edge, "Application");
+ if (Directory.Exists(root))
+ {
+ try
+ {
+ foreach (string file in Directory.EnumerateFiles(root, "setup.exe", SearchOption.AllDirectories))
+ {
+ return file;
+ }
+ }
+ catch (Exception ex)
+ {
+ ErrorLogger.LogDebug(ex);
+ }
+ }
+
+ return string.Empty;
+ }
+ }
+
+ internal static readonly string EdgeTempStub = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "SystemApps", "Microsoft.MicrosoftEdge_8wekyb3d8bbwe", "MicrosoftEdge.exe");
+
+ internal static readonly string[] OneDriveInstances = new[]
{
- Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Microsoft", "OneDrive", "OneDrive.exe"),
- Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Microsoft", "OneDrive", "Update", "OneDrive.exe"),
+ Path.Combine(Folders.OneDrive, "OneDrive.exe"),
+ Path.Combine(Folders.OneDrive, "Update", "OneDrive.exe"),
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "Microsoft OneDrive", "OneDrive.exe"),
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), "Microsoft OneDrive", "OneDrive.exe"),
};
diff --git a/.Source/GTweak/Modules/Maintenance/MemoryCleaner.cs b/.Source/GTweak/Modules/Maintenance/MemoryCleaner.cs
index 49563452..2d8c022c 100644
--- a/.Source/GTweak/Modules/Maintenance/MemoryCleaner.cs
+++ b/.Source/GTweak/Modules/Maintenance/MemoryCleaner.cs
@@ -183,12 +183,12 @@ namespace GTweak.Modules.Maintenance
return num != 0;
}
- internal void StartMemoryCleanup(bool shouldRemoveWinOld = false)
+ internal void StartMemoryCleanup(bool removeWindowsOld = false)
{
ClearFileSystemCache(true);
EmptyWorkingSetFunction();
- if (shouldRemoveWinOld)
+ if (removeWindowsOld)
{
UnlockHandleHelper.UnlockDirectory(PathTargets.Folders.WindowsOld);
diff --git a/.Source/GTweak/Modules/Tweaks/AppxPackageHandler.cs b/.Source/GTweak/Modules/Tweaks/AppxPackageHandler.cs
index aa6ef850..b375bf11 100644
--- a/.Source/GTweak/Modules/Tweaks/AppxPackageHandler.cs
+++ b/.Source/GTweak/Modules/Tweaks/AppxPackageHandler.cs
@@ -21,7 +21,7 @@ namespace GTweak.Modules.Tweaks
internal static event Action DataChanged;
internal static void OnPackagesChanged() => DataChanged?.Invoke();
- internal static bool IsOneDriveInstalled => PathTargets.Executable.OneDrive.Any(File.Exists) || (Directory.Exists(PathTargets.Folders.OneDrive) &&
+ internal static bool IsOneDriveInstalled => PathTargets.Executable.OneDriveInstances.Any(File.Exists) || (Directory.Exists(PathTargets.Folders.OneDrive) &&
Directory.EnumerateDirectories(PathTargets.Folders.OneDrive).Any(dir => File.Exists(Path.Combine(dir, "OneDrive.exe"))));
internal static bool IsEdgeInstalled => Directory.Exists(PathTargets.Folders.Edge);
@@ -174,177 +174,191 @@ namespace GTweak.Modules.Tweaks
switch (packageName)
{
- case "Widgets":
- RegistryHelper.Write(Registry.LocalMachine, @"SOFTWARE\Policies\Microsoft\Dsh", "AllowNewsAndInterests", 0, RegistryValueKind.DWord);
- break;
- case "DevHome":
- RegistryHelper.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\Microsoft\WindowsUpdate\Orchestrator\UScheduler_Oobe\DevHomeUpdate");
- break;
- case "Outlook":
- RegistryHelper.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\Microsoft\WindowsUpdate\Orchestrator\UScheduler_Oobe\OutlookUpdate");
- break;
- case "Cortana":
- RegistryHelper.Write(Registry.LocalMachine, @"SOFTWARE\Microsoft\Speech_OneCore\Preferences", "ModelDownloadAllowed", 0, RegistryValueKind.DWord);
- RegistryHelper.Write(Registry.LocalMachine, @"SOFTWARE\Policies\Microsoft\Windows\Windows Search", "AllowCloudSearch", 0, RegistryValueKind.DWord);
- RegistryHelper.Write(Registry.LocalMachine, @"SOFTWARE\Policies\Microsoft\Windows\Windows Search", "AllowCortana", 0, RegistryValueKind.DWord);
- RegistryHelper.Write(Registry.LocalMachine, @"SOFTWARE\Policies\Microsoft\Windows\Windows Search", "AllowSearchToUseLocation", 0, RegistryValueKind.DWord);
- RegistryHelper.Write(Registry.LocalMachine, @"SOFTWARE\Policies\Microsoft\Windows\Windows Search", "ConnectedSearchUseWeb", 0, RegistryValueKind.DWord);
- RegistryHelper.Write(Registry.LocalMachine, @"SOFTWARE\Policies\Microsoft\Windows\Windows Search", "DisableWebSearch", 1, RegistryValueKind.DWord);
- RegistryHelper.Write(Registry.LocalMachine, @"SOFTWARE\Policies\Microsoft\Windows\Windows Search", "AllowNewsAndInterests", 0, RegistryValueKind.DWord);
- RegistryHelper.Write(Registry.CurrentUser, @"Software\Microsoft\InputPersonalization", "RestrictImplicitInkCollection", 1, RegistryValueKind.DWord);
- RegistryHelper.Write(Registry.CurrentUser, @"Software\Microsoft\InputPersonalization", "RestrictImplicitTextCollection", 1, RegistryValueKind.DWord);
- RegistryHelper.Write(Registry.CurrentUser, @"Software\Microsoft\InputPersonalization\TrainedDataStore", "HarvestContacts", 0, RegistryValueKind.DWord);
- RegistryHelper.Write(Registry.CurrentUser, @"Software\Microsoft\Personalization\Settings", "AcceptedPrivacyPolicy", 0, RegistryValueKind.DWord);
- RegistryHelper.Write(Registry.CurrentUser, @"Software\Microsoft\Windows\CurrentVersion\Windows Search", "CortanaConsent", 0, RegistryValueKind.DWord);
- break;
- case "Phone":
- RegistryHelper.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\Microsoft\WindowsUpdate\Orchestrator\UScheduler_Oobe\CrossDeviceUpdate");
- if (RegistryHelper.KeyExists(Registry.ClassesRoot, @"*\shellex\ContextMenuHandlers\ModernSharing", true))
- {
- RegistryHelper.DeleteFolderTree(Registry.ClassesRoot, @"*\shellex\ContextMenuHandlers\SendTo");
- RegistryHelper.DeleteFolderTree(Registry.ClassesRoot, @"*\shellex\ContextMenuHandlers\ModernShare");
- }
- else
- {
- RegistryHelper.DeleteFolderTree(Registry.ClassesRoot, @"AllFilesystemObjects\shellex\ContextMenuHandlers\SendTo");
- RegistryHelper.DeleteFolderTree(Registry.ClassesRoot, @"AllFilesystemObjects\shellex\ContextMenuHandlers\ModernSharing");
- }
- CommandExecutor.RunCommandAsTrustedInstaller($@"/c reg delete ""HKEY_CLASSES_ROOT\CLSID\{{7AD84985-87B4-4a16-BE58-8B72A5B390F7}}"" /f & reg delete ""HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{{7AD84985-87B4-4a16-BE58-8B72A5B390F7}}"" /f");
+ case "Widgets": PostRemoveWidgets(); break;
+ case "DevHome": PostRemoveDevHome(); break;
+ case "Outlook": PostRemoveOutlook(); break;
+ case "Cortana": PostRemoveCortana(); break;
+ case "Phone": PostRemovePhone(); break;
+ case "Paint3D": PostRemovePaint3D(); break;
+ case "Edge": PostRemoveEdge(shouldRemoveWebView); break;
+ default:
break;
- case "Paint3D":
- try
+ }
+ }
+
+ private static void PostRemoveWidgets() => RegistryHelper.Write(Registry.LocalMachine, @"SOFTWARE\Policies\Microsoft\Dsh", "AllowNewsAndInterests", 0, RegistryValueKind.DWord);
+
+ private static void PostRemoveDevHome() => RegistryHelper.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\Microsoft\WindowsUpdate\Orchestrator\UScheduler_Oobe\DevHomeUpdate");
+
+ private static void PostRemoveOutlook() => RegistryHelper.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\Microsoft\WindowsUpdate\Orchestrator\UScheduler_Oobe\OutlookUpdate");
+
+ private static void PostRemoveCortana()
+ {
+ RegistryHelper.Write(Registry.LocalMachine, @"SOFTWARE\Microsoft\Speech_OneCore\Preferences", "ModelDownloadAllowed", 0, RegistryValueKind.DWord);
+ RegistryHelper.Write(Registry.LocalMachine, @"SOFTWARE\Policies\Microsoft\Windows\Windows Search", "AllowCloudSearch", 0, RegistryValueKind.DWord);
+ RegistryHelper.Write(Registry.LocalMachine, @"SOFTWARE\Policies\Microsoft\Windows\Windows Search", "AllowCortana", 0, RegistryValueKind.DWord);
+ RegistryHelper.Write(Registry.LocalMachine, @"SOFTWARE\Policies\Microsoft\Windows\Windows Search", "AllowSearchToUseLocation", 0, RegistryValueKind.DWord);
+ RegistryHelper.Write(Registry.LocalMachine, @"SOFTWARE\Policies\Microsoft\Windows\Windows Search", "ConnectedSearchUseWeb", 0, RegistryValueKind.DWord);
+ RegistryHelper.Write(Registry.LocalMachine, @"SOFTWARE\Policies\Microsoft\Windows\Windows Search", "DisableWebSearch", 1, RegistryValueKind.DWord);
+ RegistryHelper.Write(Registry.LocalMachine, @"SOFTWARE\Policies\Microsoft\Windows\Windows Search", "AllowNewsAndInterests", 0, RegistryValueKind.DWord);
+ RegistryHelper.Write(Registry.CurrentUser, @"Software\Microsoft\InputPersonalization", "RestrictImplicitInkCollection", 1, RegistryValueKind.DWord);
+ RegistryHelper.Write(Registry.CurrentUser, @"Software\Microsoft\InputPersonalization", "RestrictImplicitTextCollection", 1, RegistryValueKind.DWord);
+ RegistryHelper.Write(Registry.CurrentUser, @"Software\Microsoft\InputPersonalization\TrainedDataStore", "HarvestContacts", 0, RegistryValueKind.DWord);
+ RegistryHelper.Write(Registry.CurrentUser, @"Software\Microsoft\Personalization\Settings", "AcceptedPrivacyPolicy", 0, RegistryValueKind.DWord);
+ RegistryHelper.Write(Registry.CurrentUser, @"Software\Microsoft\Windows\CurrentVersion\Windows Search", "CortanaConsent", 0, RegistryValueKind.DWord);
+ }
+
+ private static void PostRemovePhone()
+ {
+ RegistryHelper.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\Microsoft\WindowsUpdate\Orchestrator\UScheduler_Oobe\CrossDeviceUpdate");
+ if (RegistryHelper.KeyExists(Registry.ClassesRoot, @"*\shellex\ContextMenuHandlers\ModernSharing", true))
+ {
+ RegistryHelper.DeleteFolderTree(Registry.ClassesRoot, @"*\shellex\ContextMenuHandlers\SendTo");
+ RegistryHelper.DeleteFolderTree(Registry.ClassesRoot, @"*\shellex\ContextMenuHandlers\ModernShare");
+ }
+ else
+ {
+ RegistryHelper.DeleteFolderTree(Registry.ClassesRoot, @"AllFilesystemObjects\shellex\ContextMenuHandlers\SendTo");
+ RegistryHelper.DeleteFolderTree(Registry.ClassesRoot, @"AllFilesystemObjects\shellex\ContextMenuHandlers\ModernSharing");
+ }
+ CommandExecutor.RunCommandAsTrustedInstaller($@"/c reg delete ""HKEY_CLASSES_ROOT\CLSID\{{7AD84985-87B4-4a16-BE58-8B72A5B390F7}}"" /f & reg delete ""HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{{7AD84985-87B4-4a16-BE58-8B72A5B390F7}}"" /f");
+ }
+
+ private static void PostRemovePaint3D()
+ {
+ try
+ {
+ using RegistryKey baseKey = Registry.ClassesRoot.OpenSubKey("SystemFileAssociations", true);
+ if (baseKey != null)
+ {
+ foreach (string subkey in baseKey.GetSubKeyNames())
{
- using RegistryKey baseKey = Registry.ClassesRoot.OpenSubKey("SystemFileAssociations", true);
- if (baseKey != null)
+ try
{
- foreach (string subkey in baseKey.GetSubKeyNames())
+ using RegistryKey assocKey = baseKey.OpenSubKey(subkey, true);
+ if (assocKey != null)
{
- try
+ using RegistryKey shellKey = assocKey.OpenSubKey("Shell", true);
+ if (shellKey != null)
{
- using RegistryKey assocKey = baseKey.OpenSubKey(subkey, true);
- if (assocKey != null)
+ if (shellKey.GetSubKeyNames().Any(k => k.Equals("3D Print", StringComparison.OrdinalIgnoreCase)))
{
- using RegistryKey shellKey = assocKey.OpenSubKey("Shell", true);
- if (shellKey != null)
- {
- if (shellKey.GetSubKeyNames().Any(k => k.Equals("3D Print", StringComparison.OrdinalIgnoreCase)))
- {
- RegistryHelper.DeleteFolderTree(Registry.ClassesRoot, $@"SystemFileAssociations\{subkey}\shell\3D Print");
- }
- }
+ RegistryHelper.DeleteFolderTree(Registry.ClassesRoot, $@"SystemFileAssociations\{subkey}\shell\3D Print");
}
}
- catch (Exception ex) { ErrorLogger.LogDebug(ex); }
}
- baseKey.Close();
}
+ catch (Exception ex) { ErrorLogger.LogDebug(ex); }
}
- catch (Exception ex) { ErrorLogger.LogDebug(ex); }
- break;
- case "Edge":
- string setupPathEdge = Directory.EnumerateFiles(Path.Combine(PathTargets.Folders.Edge, "Application"), "setup.exe", SearchOption.AllDirectories).FirstOrDefault() ?? string.Empty;
- string tempPathEdge = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "SystemApps", "Microsoft.MicrosoftEdge_8wekyb3d8bbwe", "MicrosoftEdge.exe");
+ baseKey.Close();
+ }
+ }
+ catch (Exception ex) { ErrorLogger.LogDebug(ex); }
+ }
- string[] processes = { "msedge", "edge", "edgeupdate", "edgeupdatem", "msedgewebview2", "microsoftedgeupdate", "msedgewebviewhost", "msedgeuserbroker", "usocoreworker", "widgets", "microsoftedgesh", "microsoftedgecp", "microsoftedge" };
- CommandExecutor.RunCommandAsTrustedInstaller("/c taskkill /f " + string.Join(" ", processes.Select(p => $"/im {p}.exe")));
+ private static void PostRemoveEdge(bool removeWebView)
+ {
+ string[] processes = { "msedge", "edge", "edgeupdate", "edgeupdatem", "msedgewebview2", "microsoftedgeupdate", "msedgewebviewhost", "msedgeuserbroker", "usocoreworker", "widgets", "microsoftedgesh", "microsoftedgecp", "microsoftedge" };
+ CommandExecutor.RunCommandAsTrustedInstaller("/c taskkill /f " + string.Join(" ", processes.Select(p => $"/im {p}.exe")));
- try
- {
- Directory.CreateDirectory(Path.GetDirectoryName(tempPathEdge));
- File.WriteAllBytes(tempPathEdge, Array.Empty<byte>());
- }
- catch (Exception ex) { ErrorLogger.LogDebug(ex); }
+ string setup = PathTargets.Executable.EdgeSetup;
+ string stub = PathTargets.Executable.EdgeTempStub;
- if (!string.IsNullOrEmpty(setupPathEdge))
- {
- ProcessStartInfo startInfo = new ProcessStartInfo()
- {
- FileName = setupPathEdge,
- Arguments = "--uninstall --system-level --force-uninstall --delete-profile",
- WindowStyle = ProcessWindowStyle.Hidden,
- UseShellExecute = true,
- Verb = "runas",
- CreateNoWindow = true
- };
-
- using Process process = new Process { StartInfo = startInfo };
- try
- {
- process.Start();
- process.WaitForExit();
- }
- catch (Exception ex) { ErrorLogger.LogDebug(ex); }
- }
+ try
+ {
+ Directory.CreateDirectory(Path.GetDirectoryName(stub));
+ File.WriteAllBytes(stub, Array.Empty<byte>());
+ }
+ catch (Exception ex) { ErrorLogger.LogDebug(ex); }
+
+ if (!string.IsNullOrEmpty(setup))
+ {
+ ProcessStartInfo startInfo = new ProcessStartInfo()
+ {
+ FileName = setup,
+ Arguments = "--uninstall --system-level --force-uninstall --delete-profile",
+ WindowStyle = ProcessWindowStyle.Hidden,
+ UseShellExecute = true,
+ Verb = "runas",
+ CreateNoWindow = true
+ };
- try
+ using Process process = new Process { StartInfo = startInfo };
+ try
+ {
+ process.Start();
+ process.WaitForExit();
+ }
+ catch (Exception ex) { ErrorLogger.LogDebug(ex); }
+ }
+
+ try
+ {
+ if (Directory.Exists(Path.GetDirectoryName(stub)))
+ {
+ Directory.Delete(Path.GetDirectoryName(stub), true);
+ }
+ }
+ catch (Exception ex) { ErrorLogger.LogDebug(ex); }
+
+ if (removeWebView)
+ {
+ RemoveTasks(edgeTasks);
+
+ RegistryHelper.DeleteFolderTree(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\edgeupdate", true);
+ RegistryHelper.DeleteFolderTree(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\edgeupdatem", true);
+ RegistryHelper.DeleteFolderTree(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\MicrosoftEdgeElevationService", true);
+ RegistryHelper.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\WOW6432Node\Microsoft\Edge", true);
+ RegistryHelper.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate", true);
+ RegistryHelper.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\WOW6432Node\Microsoft\EdgeWebView", true);
+ RegistryHelper.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Edge Update", true);
+ RegistryHelper.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft EdgeWebView", true);
+ RegistryHelper.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\Microsoft\EdgeWebView", true);
+ RegistryHelper.DeleteFolderTree(Registry.CurrentUser, @"Software\Microsoft\EdgeUpdate", true);
+ RegistryHelper.DeleteFolderTree(Registry.CurrentUser, @"Software\Microsoft\EdgeWebView", true);
+ RegistryHelper.DeleteFolderTree(Registry.ClassesRoot, @"AppID\MicrosoftEdgeUpdate.exe", true);
+ RegistryHelper.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Explorer\Browser Helper Objects", true);
+ RegistryHelper.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Browser Helper Objects", true);
+ RegistryHelper.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\Microsoft\WindowsUpdate\Orchestrator\UScheduler_Oobe\EdgeUpdate", true);
+
+ foreach (string dir in PathTargets.Folders.EdgeComponents)
+ {
+ if (Directory.Exists(dir))
{
- if (Directory.Exists(Path.GetDirectoryName(tempPathEdge)))
- {
- Directory.Delete(Path.GetDirectoryName(tempPathEdge), true);
- }
+ UnlockHandleHelper.UnlockDirectory(dir);
+ RemoveDirectory(dir);
}
- catch (Exception ex) { ErrorLogger.LogDebug(ex); }
+ }
+ }
- if (shouldRemoveWebView)
+ try
+ {
+ using RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\InboxApplications");
+ foreach (string subKey in key?.GetSubKeyNames() ?? Array.Empty<string>())
+ {
+ using RegistryKey subKeyEntry = key.OpenSubKey(subKey);
+ string path = subKeyEntry?.GetValue("Path") as string;
+ if (!string.IsNullOrEmpty(path) && path.Equals("Edge"))
{
- RemoveTasks(edgeTasks);
-
- RegistryHelper.DeleteFolderTree(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\edgeupdate", true);
- RegistryHelper.DeleteFolderTree(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\edgeupdatem", true);
- RegistryHelper.DeleteFolderTree(Registry.LocalMachine, @"SYSTEM\CurrentControlSet\Services\MicrosoftEdgeElevationService", true);
- RegistryHelper.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\WOW6432Node\Microsoft\Edge", true);
- RegistryHelper.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate", true);
- RegistryHelper.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\WOW6432Node\Microsoft\EdgeWebView", true);
- RegistryHelper.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Edge Update", true);
- RegistryHelper.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft EdgeWebView", true);
- RegistryHelper.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\Microsoft\EdgeWebView", true);
- RegistryHelper.DeleteFolderTree(Registry.CurrentUser, @"Software\Microsoft\EdgeUpdate", true);
- RegistryHelper.DeleteFolderTree(Registry.CurrentUser, @"Software\Microsoft\EdgeWebView", true);
- RegistryHelper.DeleteFolderTree(Registry.ClassesRoot, @"AppID\MicrosoftEdgeUpdate.exe", true);
- RegistryHelper.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Explorer\Browser Helper Objects", true);
- RegistryHelper.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Browser Helper Objects", true);
- RegistryHelper.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\Microsoft\WindowsUpdate\Orchestrator\UScheduler_Oobe\EdgeUpdate", true);
-
- foreach (string folder in new[] { "Edge", "EdgeCore", "EdgeUpdate", "Temp", "EdgeWebView" })
+ if (!removeWebView && path.Contains("WebView"))
{
- string dir = Path.Combine(Directory.GetParent(PathTargets.Folders.Edge).FullName, folder);
- UnlockHandleHelper.UnlockDirectory(dir);
- RemoveDirectory(dir);
+ continue;
}
- }
- try
- {
- using RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore\InboxApplications");
- foreach (string subKey in key?.GetSubKeyNames() ?? Array.Empty<string>())
+ if (path.EndsWith(@"\AppxManifest.xml", StringComparison.OrdinalIgnoreCase))
{
- using RegistryKey subKeyEntry = key.OpenSubKey(subKey);
- string path = subKeyEntry?.GetValue("Path") as string;
- if (!string.IsNullOrEmpty(path) && path.Equals("Edge"))
- {
- if (!shouldRemoveWebView && path.Contains("WebView"))
- {
- continue;
- }
-
- if (path.EndsWith(@"\AppxManifest.xml", StringComparison.OrdinalIgnoreCase))
- {
- path = path.Replace(@"\AppxManifest.xml", "").Trim();
- }
+ path = path.Replace(@"\AppxManifest.xml", "").Trim();
+ }
- RemoveDirectory(path);
+ RemoveDirectory(path);
- key.DeleteSubKey(subKey);
+ key.DeleteSubKey(subKey);
- return;
- }
- }
+ return;
}
- catch (Exception ex) { ErrorLogger.LogDebug(ex); }
- break;
- default:
- break;
+ }
}
+ catch (Exception ex) { ErrorLogger.LogDebug(ex); }
}
private static void RemoveDirectory(string path)
diff --git a/.Source/GTweak/View/PackagesView.xaml.cs b/.Source/GTweak/View/PackagesView.xaml.cs
index f6dc8999..8b992682 100644
--- a/.Source/GTweak/View/PackagesView.xaml.cs
+++ b/.Source/GTweak/View/PackagesView.xaml.cs
@@ -18,7 +18,7 @@ namespace GTweak.View
private readonly BackgroundQueueManager _backgroundQueue = new BackgroundQueueManager();
private readonly BackgroundWorker backgroundWorker = new BackgroundWorker();
private readonly AppxPackageHandler _packageHandler = new AppxPackageHandler();
- private bool? _isWebViewRemoval = false;
+ private bool? _webViewRemoval = false;
public PackagesView()
{
@@ -85,9 +85,9 @@ namespace GTweak.View
{
if (packageName.Equals("Edge"))
{
- _isWebViewRemoval = await OverlayDialogManager.Show("title_over_pkg", "text_over_pkg", "question_over_pkg", "btn_delete_all", "btn_keep_webview");
+ _webViewRemoval = await OverlayDialogManager.Show("title_over_pkg", "text_over_pkg", "question_over_pkg", "btn_delete_all", "btn_keep_webview");
- if (_isWebViewRemoval == null)
+ if (_webViewRemoval == null)
{
return;
}
@@ -97,7 +97,7 @@ namespace GTweak.View
{
await Dispatcher.InvokeAsync(() => { AppxPackageHandler.HandleAvailabilityStatus(packageName, true); });
- try { await AppxPackageHandler.RemoveAppxPackage(packageName, (bool)_isWebViewRemoval); }
+ try { await AppxPackageHandler.RemoveAppxPackage(packageName, (bool)_webViewRemoval); }
finally { await Dispatcher.InvokeAsync(() => { AppxPackageHandler.HandleAvailabilityStatus(packageName, false); }); }
await Dispatcher.BeginInvoke(new Action(() =>
diff --git a/.Source/GTweak/View/UtilsView.xaml.cs b/.Source/GTweak/View/UtilsView.xaml.cs
index 7d1c8228..93d59fcf 100644
--- a/.Source/GTweak/View/UtilsView.xaml.cs
+++ b/.Source/GTweak/View/UtilsView.xaml.cs
@@ -16,7 +16,7 @@ namespace GTweak.View
private readonly SystemRestoreService _systemRestore = new SystemRestoreService();
private readonly NTFSCompressor _ntfsCompressor = new NTFSCompressor();
- private bool? _isWinOldRemoval = false;
+ private bool? _windowsOldRemoval = false;
public UtilsView()
{
@@ -172,16 +172,16 @@ namespace GTweak.View
if (clearingMemory.IsWinOldExists)
{
- _isWinOldRemoval = await OverlayDialogManager.Show("title_over_more", "text_over_more", "question_over_more", "btn_agree", "btn_decline");
+ _windowsOldRemoval = await OverlayDialogManager.Show("title_over_more", "text_over_more", "question_over_more", "btn_agree", "btn_decline");
- if (_isWinOldRemoval == null)
+ if (_windowsOldRemoval == null)
{
return;
}
}
BackgroundQueueManager backgroundQueue = new BackgroundQueueManager();
- await backgroundQueue.QueueTask(delegate { clearingMemory.StartMemoryCleanup((bool)_isWinOldRemoval); });
+ await backgroundQueue.QueueTask(delegate { clearingMemory.StartMemoryCleanup((bool)_windowsOldRemoval); });
await backgroundQueue.QueueTask(delegate { NotificationManager.Info("clear_ram_noty").WithDelay(500).Perform(); });
}