Portable Tool for an Ideal Windows Setup
C# activatorbloatware-removalcsharpdebloatdebloaterdisable-servicesmonitoring-systemportableprivacy-toolsregistry-tweakssystem-tuningsystem-utilitytelemetrytweakerwindows-10windows-11windows-debloatwindows-defenderwindows-optimizationwindows-tweaks
-backup server and connection check, if the site is blocked in the country -refactoring
Greedeks5f7446d77771
diff --git a/.Source/GTweak/Utilities/Tweaks/Firewall.cs b/.Source/GTweak/Utilities/Tweaks/Firewall.csindex 42cba9a6..135acb78 100644--- a/.Source/GTweak/Utilities/Tweaks/Firewall.cs+++ b/.Source/GTweak/Utilities/Tweaks/Firewall.cs@@ -34,26 +34,36 @@ namespace GTweak.Utilities.Tweaks{if (CheckRulesWindows(nameRules) && isChoose){- Parallel.Invoke(- () => { RulesUpdateIN(isChoose, Settings.PathSystemDisk + programPaths["MoUso_New"], nameRules); },- () => { RulesUpdateIN(isChoose, Settings.PathSystemDisk + programPaths["MoUso_Old"], string.Concat(nameRules," (Old Way)")); },- () => { RulesUpdateIN(isChoose, Settings.PathSystemDisk + programPaths["Uso"], string.Concat(nameRules," (Update Orchestrator)")); },- () => { RulesUpdateOUT(isChoose, Settings.PathSystemDisk + @programPaths["MoUso_New"], nameRules); },- () => { RulesUpdateOUT(isChoose, Settings.PathSystemDisk + programPaths["MoUso_Old"], string.Concat(nameRules, " (Old Way)")); },- () => { RulesUpdateOUT(isChoose, Settings.PathSystemDisk + programPaths["Uso"], string.Concat(nameRules, " (Update Orchestrator)")); });+ Parallel.Invoke(() => {+ RulesUpdateIN(isChoose, Settings.PathSystemDisk + programPaths["MoUso_New"], nameRules);+ RulesUpdateIN(isChoose, Settings.PathSystemDisk + programPaths["MoUso_Old"], string.Concat(nameRules, " (Old Way)"));+ RulesUpdateIN(isChoose, Settings.PathSystemDisk + programPaths["Uso"], string.Concat(nameRules," (Update Orchestrator)"));+ },+ () => {+ RulesUpdateOUT(isChoose, Settings.PathSystemDisk + @programPaths["MoUso_New"], nameRules);+ RulesUpdateOUT(isChoose, Settings.PathSystemDisk + programPaths["MoUso_Old"], string.Concat(nameRules, " (Old Way)"));+ RulesUpdateOUT(isChoose, Settings.PathSystemDisk + programPaths["Uso"], string.Concat(nameRules, " (Update Orchestrator)"));+ });}else{- try {- RulesUpdateIN(isChoose, Settings.PathSystemDisk + programPaths["MoUso_New"], nameRules);- RulesUpdateIN(isChoose, Settings.PathSystemDisk + programPaths["MoUso_Old"], string.Concat(nameRules, " (Old Way)"));- RulesUpdateIN(isChoose, Settings.PathSystemDisk + programPaths["Uso"], string.Concat(nameRules, " (Update Orchestrator)"));- } catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }- try {- RulesUpdateOUT(isChoose, Settings.PathSystemDisk + programPaths["MoUso_New"], nameRules);- RulesUpdateOUT(isChoose, Settings.PathSystemDisk + programPaths["MoUso_Old"], string.Concat(nameRules, " (Old Way)"));- RulesUpdateOUT(isChoose, Settings.PathSystemDisk + programPaths["Uso"], string.Concat(nameRules, " (Update Orchestrator)"));- } catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }+ Parallel.Invoke(() =>+ {+ try+ {+ RulesUpdateIN(isChoose, Settings.PathSystemDisk + programPaths["MoUso_New"], nameRules);+ RulesUpdateIN(isChoose, Settings.PathSystemDisk + programPaths["MoUso_Old"], string.Concat(nameRules, " (Old Way)"));+ RulesUpdateIN(isChoose, Settings.PathSystemDisk + programPaths["Uso"], string.Concat(nameRules, " (Update Orchestrator)"));+ }+ catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }+ try+ {+ RulesUpdateOUT(isChoose, Settings.PathSystemDisk + programPaths["MoUso_New"], nameRules);+ RulesUpdateOUT(isChoose, Settings.PathSystemDisk + programPaths["MoUso_Old"], string.Concat(nameRules, " (Old Way)"));+ RulesUpdateOUT(isChoose, Settings.PathSystemDisk + programPaths["Uso"], string.Concat(nameRules, " (Update Orchestrator)"));+ }+ catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); }+ });}}catchdiff --git a/.Source/GTweak/Utilities/Tweaks/SystemData.cs b/.Source/GTweak/Utilities/Tweaks/SystemData.csindex 8f1782b3..6277ee8d 100644--- a/.Source/GTweak/Utilities/Tweaks/SystemData.cs+++ b/.Source/GTweak/Utilities/Tweaks/SystemData.cs@@ -110,11 +110,17 @@ namespace GTweak.Utilitiesinternal sealed class ClientInternetProtocol{- [JsonProperty("query")]+ [JsonProperty("ip")]internal string Ip { get; set; }- [JsonProperty("countryCode")]+ [JsonProperty("country")]internal string Country { get; set; }++ [JsonProperty("query")]+ internal string Ip_Reserve { get; set; }++ [JsonProperty("countryCode")]+ internal string Country_Reserve { get; set; }}internal sealed class СomputerСonfiguration@@ -235,7 +241,9 @@ namespace GTweak.Utilitiestry {TimeSpan timeout = TimeSpan.FromSeconds(5.0);Task<IPAddress> _task = Task.Run(() => {- return Dns.GetHostEntry("google.com").AddressList[0];+ return !string.IsNullOrEmpty(Dns.GetHostEntry("google.com").AddressList[0].ToString())+ ? Dns.GetHostEntry("google.com").AddressList[0]+ : Dns.GetHostEntry("baidu.com.com").AddressList[0];});if (!_task.Wait(timeout))return false;@@ -255,7 +263,10 @@ namespace GTweak.Utilitiestry{HttpClient client = new HttpClient { Timeout = TimeSpan.FromSeconds(5.0) };- clientInternetProtocol = JsonConvert.DeserializeObject<ClientInternetProtocol>(client.GetStringAsync("http://ip-api.com/json/?fields=61439").Result);+ clientInternetProtocol = JsonConvert.DeserializeObject<ClientInternetProtocol>(client.GetStringAsync("https://ipinfo.io/json").Result);++ if (string.IsNullOrEmpty(clientInternetProtocol.Ip) || string.IsNullOrEmpty(clientInternetProtocol.Country))+ clientInternetProtocol = JsonConvert.DeserializeObject<ClientInternetProtocol>(client.GetStringAsync("http://ip-api.com/json/?fields=61439").Result);}catch{@@ -271,9 +282,12 @@ namespace GTweak.Utilitiesif (!string.IsNullOrEmpty(clientInternetProtocol.Ip) || !string.IsNullOrEmpty(clientInternetProtocol.Country)){СonfigurationData["IpAddress"] = clientInternetProtocol.Ip + " (" + clientInternetProtocol.Country + ")";-- if (isNoInternetConnection)- isNoInternetConnection = false;+ isNoInternetConnection = false && isNoInternetConnection;+ }+ else if (!string.IsNullOrEmpty(clientInternetProtocol.Ip_Reserve) || !string.IsNullOrEmpty(clientInternetProtocol.Country_Reserve))+ {+ СonfigurationData["IpAddress"] = clientInternetProtocol.Ip_Reserve + " (" + clientInternetProtocol.Country_Reserve + ")";+ isNoInternetConnection = false && isNoInternetConnection;}else{diff --git a/.Source/GTweak/Utilities/Tweaks/UninstallingApps.cs b/.Source/GTweak/Utilities/Tweaks/UninstallingApps.csindex f4aa0621..0d387fdd 100644--- a/.Source/GTweak/Utilities/Tweaks/UninstallingApps.cs+++ b/.Source/GTweak/Utilities/Tweaks/UninstallingApps.cs@@ -4,14 +4,12 @@ using System;using System.Collections.Generic;using System.Diagnostics;using System.IO;-using System.Windows;namespace GTweak.Utilities.Tweaks{internal sealed class UninstallingApps{- internal static string UserAppsList { get => listApps; set => listApps = value; }- private static string listApps = string.Empty;+ internal static string UserAppsList { get; set; } = string.Empty;internal static bool IsOneDriveInstalled => File.Exists(Environment.ExpandEnvironmentVariables(@"%userprofile%\AppData\Local\Microsoft\OneDrive\OneDrive.exe"));private static bool isLocalAccount = false;@@ -129,25 +127,27 @@ namespace GTweak.Utilities.Tweaks{if (appName != "OneDrive"){- Process process = new Process();- process.StartInfo.UseShellExecute = false;- process.StartInfo.CreateNoWindow = true;- process.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;- process.EnableRaisingEvents = true;- process.StartInfo.FileName = "powershell.exe";-- process.StartInfo.Arguments = "Get-AppxProvisionedPackage -online | where-object {$_.PackageName -like '*" + appName + "*'} | Remove-AppxProvisionedPackage -alluser -online –Verbose";- process.Start();-- foreach (var appDelete in listAppsScipt[appName])+ using (Process process = new Process()){- process.StartInfo.Arguments = string.Format("Get-AppxPackage -Name " + appDelete + " -AllUsers | Remove-AppxPackage");+ process.StartInfo.UseShellExecute = false;+ process.StartInfo.CreateNoWindow = true;+ process.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;+ process.EnableRaisingEvents = true;+ process.StartInfo.FileName = "powershell.exe";++ process.StartInfo.Arguments = "Get-AppxProvisionedPackage -online | where-object {$_.PackageName -like '*" + appName + "*'} | Remove-AppxProvisionedPackage -alluser -online –Verbose";process.Start();- }- process.WaitForExit();+ foreach (var appDelete in listAppsScipt[appName])+ {+ process.StartInfo.Arguments = string.Format("Get-AppxPackage -Name " + appDelete + " -AllUsers | Remove-AppxPackage");+ process.Start();+ }- process.Dispose();+ process.WaitForExit();++ process.Dispose();+ }switch (appName){@@ -170,28 +170,30 @@ namespace GTweak.Utilities.Tweaks{try{- Process process = new Process();- process.StartInfo.UseShellExecute = false;- process.StartInfo.CreateNoWindow = true;- process.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;- process.EnableRaisingEvents = true;- process.StartInfo.FileName = "powershell.exe";-- foreach (var appNm in listAppsScipt)+ using (Process process = new Process()){- process.StartInfo.Arguments = "Get-AppxProvisionedPackage -online | where-object {$_.PackageName -like '*" + appNm + "*'} | Remove-AppxProvisionedPackage -alluser -online –Verbose";- process.Start();+ process.StartInfo.UseShellExecute = false;+ process.StartInfo.CreateNoWindow = true;+ process.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;+ process.EnableRaisingEvents = true;+ process.StartInfo.FileName = "powershell.exe";- foreach (string appDelete in appNm.Value)+ foreach (var appNm in listAppsScipt){- process.StartInfo.Arguments = string.Format("Get-AppxPackage -Name " + appDelete + " -AllUsers | Remove-AppxPackage");+ process.StartInfo.Arguments = "Get-AppxProvisionedPackage -online | where-object {$_.PackageName -like '*" + appNm + "*'} | Remove-AppxProvisionedPackage -alluser -online –Verbose";process.Start();++ foreach (string appDelete in appNm.Value)+ {+ process.StartInfo.Arguments = string.Format("Get-AppxPackage -Name " + appDelete + " -AllUsers | Remove-AppxPackage");+ process.Start();+ }}- }- process.WaitForExit();-- process.Dispose();+ process.WaitForExit();++ process.Dispose();+ }WidgetsTweak(true);CortanaTweak(true);