From 066ac20de922ea242c9bec6be10642ecb69abd23 Mon Sep 17 00:00:00 2001 From: rayenghanmi Date: Mon, 15 Apr 2024 22:15:55 +0100 Subject: [PATCH] v0.8.1 hotfix --- App.xaml.cs | 4 +- CHANGELOG.md | 16 +++++++ Helpers/OptimizationOptions.cs | 79 +++++++++++++++++++-------------- Package.appxmanifest | 2 +- RyTuneX.csproj | 30 ++++++------- Views/DebloatSystemPage.xaml | 14 +----- Views/DebloatSystemPage.xaml.cs | 40 ++++++++++++----- Views/SettingsPage.xaml | 1 + app.manifest | 2 +- 9 files changed, 110 insertions(+), 78 deletions(-) diff --git a/App.xaml.cs b/App.xaml.cs index c57d8a3..ea34441 100644 --- a/App.xaml.cs +++ b/App.xaml.cs @@ -109,9 +109,7 @@ protected async override void OnLaunched(LaunchActivatedEventArgs args) { base.OnLaunched(args); - var showWelcomeNotification = ShouldShowWelcomeNotification(); - - if (showWelcomeNotification) + if (ShouldShowWelcomeNotification()) { await LogHelper.Log("Showing Welcome Notification"); App.MainWindow.DispatcherQueue.TryEnqueue(DispatcherQueuePriority.Low, () => diff --git a/CHANGELOG.md b/CHANGELOG.md index 9294f36..8692ef6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,22 @@ All notable changes to this branch will be documented in this file. +## 0.8.1 - Released + +> This is a hotfix for version 0.8.0 + +## Added + +- Add Simplified Chinese translation + +## Fixes + +- [x] Resolved an issue stopping users on Windows 10 from using `Debloat`. + +## Known Issues + +- This hotfix broke the ability to remove `MicrosoftEdge` (will be fixed in the next version). + ## 0.8.0 - Released ### Fixes diff --git a/Helpers/OptimizationOptions.cs b/Helpers/OptimizationOptions.cs index 8ee1ec7..7a7afd2 100644 --- a/Helpers/OptimizationOptions.cs +++ b/Helpers/OptimizationOptions.cs @@ -3,8 +3,6 @@ using System.Collections.ObjectModel; using System.Management.Automation; using Microsoft.UI.Xaml.Controls; -using Microsoft.UI.Xaml; -using System.Reflection; namespace RyTuneX.Helpers; internal class OptimizationOptions @@ -13,51 +11,64 @@ public static List> GetUWPApps(bool uninstallableOn { var installedApps = new List>(); - using (var PowerShellInstance = PowerShell.Create()) + string command; + if (uninstallableOnly) { - LogHelper.Log("Getting Installed Apps [OptimizationOptions.cs]"); - PowerShellInstance.AddScript("Set-ExecutionPolicy RemoteSigned -Scope Process"); - PowerShellInstance.AddScript("Import-Module Appx") - .AddArgument("-ExecutionPolicy Bypass"); + command = @"powershell.exe -Command ""Get-AppxPackage | Where-Object { $_.NonRemovable -eq $false } | Select-Object Name,InstallLocation"""; + } + else + { + command = @"powershell.exe -Command ""Get-AppxPackage | Select-Object Name,InstallLocation"""; + } - if (uninstallableOnly) + try + { + using var process = new Process { - PowerShellInstance.AddScript(@"Get-AppxPackage | Where {$_.NonRemovable -like ""False""} | Select Name,InstallLocation"); - } - else + StartInfo = new ProcessStartInfo + { + FileName = "cmd.exe", + Arguments = $"/C {command}", + RedirectStandardOutput = true, + UseShellExecute = false, + CreateNoWindow = true + } + }; { - PowerShellInstance.AddScript("Get-AppxPackage | Select Name,InstallLocation"); - } + process.Start(); - string[] tmp; - Collection psResult; - try - { - psResult = PowerShellInstance.Invoke(); - } - catch (Exception ex) - { - Debug.WriteLine(ex.Message); - return installedApps; - } + /* Skip the first two lines as they contain headers + Removing this will cause two apps to appear named + "----" and "Name" */ + process.StandardOutput.ReadLine(); + process.StandardOutput.ReadLine(); + process.StandardOutput.ReadLine(); - if (psResult == null) - { - return installedApps; - } - foreach (var x in psResult) - { - tmp = x.ToString().Replace("@", string.Empty).Replace("{", string.Empty).Replace("}", string.Empty).Replace("Name=", string.Empty).Replace("InstallLocation=", string.Empty).Trim().Split(';'); - if (!installedApps.Exists(i => i.Key == tmp[0])) + // Read the output directly + while (!process.StandardOutput.EndOfStream) { - installedApps.Add(new KeyValuePair(tmp[0], tmp[1])); + var line = process.StandardOutput.ReadLine(); + var parts = line?.Split(new[] { ' ' }, 2, StringSplitOptions.RemoveEmptyEntries); + if (parts?.Length == 2 && !installedApps.Exists(i => i.Key == parts[0])) + { + installedApps.Add(new KeyValuePair(parts[0], parts[1])); + } } + + process.WaitForExit(); } } - LogHelper.Log("Returning Installed Apps [OptimizationOptions.cs]"); + catch (Exception ex) + { + Debug.WriteLine(ex.Message); + return installedApps; + } + + LogHelper.Log("Returning Installed Apps [GetUWPApps]"); return installedApps; } + internal static bool ServiceExists(string serviceName) { return Array.Exists(ServiceController.GetServices(), (serviceController => serviceController.ServiceName.Equals(serviceName))); diff --git a/Package.appxmanifest b/Package.appxmanifest index 88c19f3..e8a5b31 100644 --- a/Package.appxmanifest +++ b/Package.appxmanifest @@ -13,7 +13,7 @@ + Version="0.8.1.0" /> diff --git a/RyTuneX.csproj b/RyTuneX.csproj index b5149fb..305ed13 100644 --- a/RyTuneX.csproj +++ b/RyTuneX.csproj @@ -41,7 +41,7 @@ - + @@ -49,16 +49,16 @@ - - - - - - - + + + + + + + - + @@ -99,26 +99,26 @@ - + - + - + - + - + - + diff --git a/Views/DebloatSystemPage.xaml b/Views/DebloatSystemPage.xaml index 8500f43..a84cc5c 100644 --- a/Views/DebloatSystemPage.xaml +++ b/Views/DebloatSystemPage.xaml @@ -10,10 +10,6 @@ xmlns:interactivity="using:Microsoft.Xaml.Interactivity" mc:Ignorable="d"> - - - - @@ -27,7 +23,7 @@ - + @@ -55,17 +51,9 @@ - - - -