Skip to content

Portable Tool for an Ideal Windows Setup

add MoNotificationUx.exe to block Windows Update notifications and centralize links

Greedeks387376f6ec1c
diff --git a/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs b/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs
index 908718be..ee837d61 100644
--- a/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs
+++ b/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs
@@ -615,7 +615,7 @@ namespace GTweak.Utilities.Configuration
using HttpClient client = new HttpClient { Timeout = TimeSpan.FromSeconds(5) };
- foreach (string url in new[] { "https://free.freeipapi.com/api/json/", "https://api.db-ip.com/v2/free/self", "https://ipapi.co/json/", "https://reallyfreegeoip.org/json/", "https://get.geojs.io/v1/ip/geo.json", "http://ip-api.com/json/" })
+ foreach (string url in PathLocator.Links.IpServices)
{
try
{
@@ -683,7 +683,7 @@ namespace GTweak.Utilities.Configuration
try
{
- HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create("https://api.github.com/repos/greedeks/gtweak/releases/latest");
+ HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(PathLocator.Links.GitHubApi);
webRequest.ContentType = "application/json";
webRequest.UserAgent = "Nothing";
diff --git a/.Source/GTweak/Utilities/Controls/PathLocator.cs b/.Source/GTweak/Utilities/Controls/PathLocator.cs
index 83e45fe2..085a09ba 100644
--- a/.Source/GTweak/Utilities/Controls/PathLocator.cs
+++ b/.Source/GTweak/Utilities/Controls/PathLocator.cs
@@ -235,35 +235,38 @@ namespace GTweak.Utilities.Controls
internal static (string Normal, string Block) FindWindowsUpdateExe(string normalName, string blockName)
{
- static string FindFile(string fileName)
+ static string TryFind(string name)
{
- string uusPath = Path.Combine(Folders.SystemDrive, "Windows", "UUS", "amd64", fileName);
- string system32Path = Path.Combine(Environment.SystemDirectory, fileName);
-
- if (File.Exists(uusPath))
+ if (!string.IsNullOrWhiteSpace(name))
{
- return uusPath;
- }
+ try
+ {
+ string path = Path.Combine(Folders.SystemDrive, "Windows", "UUS", "amd64", name);
- if (File.Exists(system32Path))
- {
- return system32Path;
+ if (File.Exists(path))
+ {
+ return path;
+ }
+
+ path = Path.Combine(Environment.SystemDirectory, name);
+ return File.Exists(path) ? path : string.Empty;
+ }
+ catch { return string.Empty; }
}
- return null;
+ return string.Empty;
}
- string normalPath = FindFile(normalName);
- string blockPath = FindFile(blockName);
-
- if (normalPath != null)
+ string normalPath = TryFind(normalName);
+ if (!string.IsNullOrEmpty(normalPath))
{
- return (normalPath, Path.Combine(Path.GetDirectoryName(normalPath), blockName));
+ return (normalPath, Path.Combine(Path.GetDirectoryName(normalPath)!, blockName));
}
- if (blockPath != null)
+ string blockPath = TryFind(blockName);
+ if (!string.IsNullOrEmpty(blockPath))
{
- return (Path.Combine(Path.GetDirectoryName(blockPath), normalName), blockPath);
+ return (Path.Combine(Path.GetDirectoryName(blockPath)!, normalName), blockPath);
}
return (string.Empty, string.Empty);
@@ -293,6 +296,8 @@ namespace GTweak.Utilities.Controls
internal static (string Normal, string Block) WaaSMedic => FindWindowsUpdateExe("WaaSMedicAgent.exe", "BlockUpdateAgent-GTweak.exe");
+ internal static (string Normal, string Block) MoNotificationUx => FindWindowsUpdateExe("MoNotificationUx.exe", "BlockUpdateNotify-GTweak.exe");
+
internal static readonly string MpCmdRun = Path.Combine(Folders.SystemDrive, "Program Files", "Windows Defender", "MpCmdRun.exe");
internal static readonly string DisablingWD = Path.Combine(Folders.DefenderBackup, "DisablingWD.exe");
@@ -322,5 +327,28 @@ namespace GTweak.Utilities.Controls
internal const string SubKey = @"Software\GTweak";
internal static readonly string BaseKey = @$"HKEY_CURRENT_USER\{SubKey}";
}
+
+ internal static class Links
+ {
+ internal const string GitHub = "https://github.com/Greedeks";
+
+ internal const string Telegram = "https://t.me/Greedeks";
+
+ internal const string Steam = "https://steamcommunity.com/id/greedeks/";
+
+ internal const string GitHubLatest = "https://github.com/Greedeks/GTweak/releases/latest/download/GTweak.exe";
+
+ internal const string GitHubApi = "https://api.github.com/repos/greedeks/gtweak/releases/latest";
+
+ internal static readonly IReadOnlyList<string> IpServices = Array.AsReadOnly(new[]
+ {
+ "https://free.freeipapi.com/api/json/",
+ "https://api.db-ip.com/v2/free/self",
+ "https://ipapi.co/json/",
+ "https://reallyfreegeoip.org/json/",
+ "https://get.geojs.io/v1/ip/geo.json",
+ "http://ip-api.com/json/"
+ });
+ }
}
}
diff --git a/.Source/GTweak/Utilities/Controls/SettingsEngine.cs b/.Source/GTweak/Utilities/Controls/SettingsEngine.cs
index 86192b1f..10659dbe 100644
--- a/.Source/GTweak/Utilities/Controls/SettingsEngine.cs
+++ b/.Source/GTweak/Utilities/Controls/SettingsEngine.cs
@@ -176,8 +176,8 @@ namespace GTweak.Utilities.Controls
RegistryHelp.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\Microsoft\Tracing\GTweak_RASAPI32");
RegistryHelp.DeleteFolderTree(Registry.LocalMachine, @"SOFTWARE\Microsoft\Tracing\GTweak_RASMANCS");
- CommandExecutor.RunCommand($"/c taskkill /f /im \"{currentName}\" & choice /c y /n /d y /t 3 & del \"{currentLocation}\" & " +
- @$"rd /s /q ""{PathLocator.Folders.Workspace}"" & rd /s /q ""{Environment.SystemDirectory}\config\systemprofile\AppData\Local\GTweak""");
+ CommandExecutor.RunCommand("/c " + CommandExecutor.CleanCommand(string.Join(" & ", new[] { $@"taskkill /f /im ""{currentName}""", "choice /c y /n /d y /t 3", $@"del ""{currentLocation}""",
+ $@"rd /s /q ""{PathLocator.Folders.Workspace}""", $@"rd /s /q ""{Environment.SystemDirectory}\config\systemprofile\AppData\Local\GTweak""" })));
}
catch (Exception ex) { ErrorLogging.LogDebug(ex); }
}
diff --git a/.Source/GTweak/Utilities/Helpers/CommandExecutor.cs b/.Source/GTweak/Utilities/Helpers/CommandExecutor.cs
index e53d3ee1..9cdc8537 100644
--- a/.Source/GTweak/Utilities/Helpers/CommandExecutor.cs
+++ b/.Source/GTweak/Utilities/Helpers/CommandExecutor.cs
@@ -149,7 +149,7 @@ namespace GTweak.Utilities.Helpers
return string.Empty;
}
- var lines = string.IsNullOrEmpty(rawCommand) ? new List<string>() : rawCommand.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).Select(line => line.Trim()).Where(line => !string.IsNullOrEmpty(line)).Select(line => Regex.Replace(line, @"\s+", " ")).ToList();
+ List<string> lines = string.IsNullOrEmpty(rawCommand) ? new List<string>() : rawCommand.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).Select(line => line.Trim()).Where(line => !string.IsNullOrEmpty(line)).Select(line => Regex.Replace(line, @"\s+", " ")).ToList();
if (lines.Count == 0)
{
diff --git a/.Source/GTweak/Utilities/Tweaks/ServicesTweaks.cs b/.Source/GTweak/Utilities/Tweaks/ServicesTweaks.cs
index 73fcd589..289d4933 100644
--- a/.Source/GTweak/Utilities/Tweaks/ServicesTweaks.cs
+++ b/.Source/GTweak/Utilities/Tweaks/ServicesTweaks.cs
@@ -14,7 +14,7 @@ namespace GTweak.Utilities.Tweaks
{
internal static Dictionary<string, object> ControlStates = new Dictionary<string, object>();
private readonly ControlWriterManager _сontrolWriter = new ControlWriterManager(ControlStates);
- private readonly (string Normal, string Block)[] _updateFiles = new[] { PathLocator.Executable.UsoClient, PathLocator.Executable.WorkerCore, PathLocator.Executable.WuauClient, PathLocator.Executable.WaaSMedic };
+ private readonly (string Normal, string Block)[] _updateFiles = new[] { PathLocator.Executable.UsoClient, PathLocator.Executable.WorkerCore, PathLocator.Executable.WuauClient, PathLocator.Executable.WaaSMedic, PathLocator.Executable.MoNotificationUx };
internal void AnalyzeAndUpdate()
{
diff --git a/.Source/GTweak/Windows/MainWindow.xaml.cs b/.Source/GTweak/Windows/MainWindow.xaml.cs
index 9425dc65..dd9d163b 100644
--- a/.Source/GTweak/Windows/MainWindow.xaml.cs
+++ b/.Source/GTweak/Windows/MainWindow.xaml.cs
@@ -217,9 +217,9 @@ namespace GTweak.Windows
{
Process.Start(new ProcessStartInfo(((System.Windows.Controls.Image)sender).Uid switch
{
- "git" => "https://github.com/Greedeks",
- "tg" => "https://t.me/Greedeks",
- _ => "https://steamcommunity.com/id/greedeks/"
+ "git" => PathLocator.Links.GitHub,
+ "tg" => PathLocator.Links.Telegram,
+ _ => PathLocator.Links.Steam
})
{ UseShellExecute = true });
}
diff --git a/.Source/GTweak/Windows/UpdateWindow.xaml.cs b/.Source/GTweak/Windows/UpdateWindow.xaml.cs
index 7b690939..6aa177d4 100644
--- a/.Source/GTweak/Windows/UpdateWindow.xaml.cs
+++ b/.Source/GTweak/Windows/UpdateWindow.xaml.cs
@@ -44,7 +44,7 @@ namespace GTweak.Windows
{
CommandExecutor.RunCommand($"/c taskkill /f /im \"{SettingsEngine.currentName}\" && timeout /t 2 && del \"{SettingsEngine.currentLocation}\" && ren {tempFileName} \"{SettingsEngine.currentName}\" && \"{SettingsEngine.currentLocation}\"");
};
- webClient.DownloadFileAsync(new Uri("https://github.com/Greedeks/GTweak/releases/latest/download/GTweak.exe"), tempFileName);
+ webClient.DownloadFileAsync(new Uri(PathLocator.Links.GitHubLatest), tempFileName);
}
catch
{