Skip to content

Portable Tool for an Ideal Windows Setup

add processing the uninstall argument via cmd & gen unique name debg v 5.2.2

Greedeks68eedcf4093f
diff --git a/.Source/GTweak/App.xaml b/.Source/GTweak/App.xaml
index 0a324045..d1fd8f54 100644
--- a/.Source/GTweak/App.xaml
+++ b/.Source/GTweak/App.xaml
@@ -2,7 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:GTweak"
- StartupUri="Windows/LoadingWindow.xaml">
+ Startup="App_Startup">
<Application.Resources>
<ResourceDictionary>
diff --git a/.Source/GTweak/App.xaml.cs b/.Source/GTweak/App.xaml.cs
index 1e2e4110..cbab2fb3 100644
--- a/.Source/GTweak/App.xaml.cs
+++ b/.Source/GTweak/App.xaml.cs
@@ -1,5 +1,6 @@
using GTweak.Utilities.Controls;
using GTweak.Utilities.Helpers;
+using GTweak.Windows;
using System;
using System.Globalization;
using System.Linq;
@@ -17,6 +18,8 @@ namespace GTweak
internal static event EventHandler ImportTweaksUpdate;
internal static string GettingSystemLanguage => Regex.Replace(CultureInfo.CurrentCulture.ToString(), @"-.+$", "", RegexOptions.Multiline);
+ internal static void UpdateImport() => ImportTweaksUpdate?.Invoke(default, EventArgs.Empty);
+ private void LogError(Exception ex, [CallerMemberName] string memberName = "") => ErrorLogging.LogWritingFile(ex, memberName);
public App()
{
@@ -26,6 +29,23 @@ namespace GTweak
AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
}
+ private void App_Startup(object sender, StartupEventArgs e)
+ {
+ if (e.Args.Any(arg => arg.Equals("uninstall", StringComparison.OrdinalIgnoreCase)))
+ {
+ SettingsRepository.SelfRemoval();
+ return;
+ }
+
+ Language = RegistryHelp.GetValue(@"HKEY_CURRENT_USER\Software\GTweak", "Language", GettingSystemLanguage);
+ Theme = RegistryHelp.GetValue(@"HKEY_CURRENT_USER\Software\GTweak", "Theme", "Dark");
+
+ BlockRunTweaker.CheckingApplicationCopies();
+ BlockRunTweaker.CheckingSystemRequirements();
+
+ new LoadingWindow().Show();
+ }
+
private void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
LogError(e.Exception);
@@ -40,16 +60,6 @@ namespace GTweak
Environment.Exit(0);
}
- private void LogError(Exception ex, [CallerMemberName] string memberName = "") => ErrorLogging.LogWritingFile(ex, memberName);
-
- internal static void UpdateImport() => ImportTweaksUpdate?.Invoke(default, EventArgs.Empty);
-
- internal static void ViewingSettings()
- {
- Language = RegistryHelp.GetValue(@"HKEY_CURRENT_USER\Software\GTweak", "Language", GettingSystemLanguage);
- Theme = RegistryHelp.GetValue(@"HKEY_CURRENT_USER\Software\GTweak", "Theme", "Dark");
- }
-
internal static string Language
{
set
diff --git a/.Source/GTweak/Properties/AssemblyInfo.cs b/.Source/GTweak/Properties/AssemblyInfo.cs
index 362340d3..c1c1eb30 100644
--- a/.Source/GTweak/Properties/AssemblyInfo.cs
+++ b/.Source/GTweak/Properties/AssemblyInfo.cs
@@ -7,9 +7,9 @@ using System.Windows;
[assembly: AssemblyProduct("GTweak")]
[assembly: AssemblyCopyright("© 2024-2025 Greedeks")]
[assembly: AssemblyTrademark("Greedeks")]
-[assembly: AssemblyInformationalVersion("Build: 5.2.1")]
-[assembly: AssemblyVersion("5.2.46.779")]
-[assembly: AssemblyFileVersion("5.2.46.779")]
+[assembly: AssemblyInformationalVersion("Build: 5.2.2")]
+[assembly: AssemblyVersion("5.2.31.104")]
+[assembly: AssemblyFileVersion("5.2.31.104")]
[assembly: ComVisible(false)]
diff --git a/.Source/GTweak/Properties/AssemblyInfo.tt b/.Source/GTweak/Properties/AssemblyInfo.tt
index 525384f3..d22b0d50 100644
--- a/.Source/GTweak/Properties/AssemblyInfo.tt
+++ b/.Source/GTweak/Properties/AssemblyInfo.tt
@@ -20,7 +20,7 @@ using System.Windows;
ResourceDictionaryLocation.SourceAssembly
)]
<#+
- private const string buildVersion = "Build: 5.2.1";
+ private const string buildVersion = "Build: 5.2.2";
private string GenerateVersion()
{
diff --git a/.Source/GTweak/Utilities/Controls/SettingsRepository.cs b/.Source/GTweak/Utilities/Controls/SettingsRepository.cs
index f769320d..12bc4df5 100644
--- a/.Source/GTweak/Utilities/Controls/SettingsRepository.cs
+++ b/.Source/GTweak/Utilities/Controls/SettingsRepository.cs
@@ -169,7 +169,7 @@ 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 \"{new FileInfo(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath).Name}\" & " +
+ CommandExecutor.RunCommand($"/c taskkill /f /im \"{currentName}\" & choice /c y /n /d y /t 3 & del \"{currentLocation}\" & " +
@$"rd /s /q ""{StoragePaths.FolderLocation}"" & rd /s /q ""{Environment.SystemDirectory}\config\systemprofile\AppData\Local\GTweak""");
}
catch (Exception ex) { ErrorLogging.LogDebug(ex); }
diff --git a/.Source/GTweak/Windows/LoadingWindow.xaml.cs b/.Source/GTweak/Windows/LoadingWindow.xaml.cs
index f61f66a5..a319e965 100644
--- a/.Source/GTweak/Windows/LoadingWindow.xaml.cs
+++ b/.Source/GTweak/Windows/LoadingWindow.xaml.cs
@@ -15,12 +15,7 @@ namespace GTweak.Windows
{
public LoadingWindow()
{
- App.ViewingSettings();
-
InitializeComponent();
-
- BlockRunTweaker.CheckingApplicationCopies();
- BlockRunTweaker.CheckingSystemRequirements();
}
private void Window_ContentRendered(object sender, EventArgs e)
@@ -79,7 +74,6 @@ namespace GTweak.Windows
new TypewriterAnimation((string)FindResource($"text{++index}_load"), TextLoad, TimeSpan.FromMilliseconds(200));
}
-
private void Window_Closing(object sender, CancelEventArgs e)
{
Closing -= Window_Closing;
diff --git a/.Source/GTweak/Windows/UpdateWindow.xaml.cs b/.Source/GTweak/Windows/UpdateWindow.xaml.cs
index 60961530..4a3e7627 100644
--- a/.Source/GTweak/Windows/UpdateWindow.xaml.cs
+++ b/.Source/GTweak/Windows/UpdateWindow.xaml.cs
@@ -69,6 +69,8 @@ namespace GTweak.Windows
try
{
+ string tempFileName = $"GTweak_{Guid.NewGuid().ToString("N").Substring(0, 8)}.exe";
+
using WebClient webClient = new WebClient();
webClient.DownloadProgressChanged += (s, e) =>
{
@@ -77,9 +79,9 @@ namespace GTweak.Windows
};
webClient.DownloadFileCompleted += delegate
{
- CommandExecutor.RunCommand($"/c taskkill /f /im \"{SettingsRepository.currentName}\" && timeout /t 1 && del \"{SettingsRepository.currentLocation}\" && ren Git-GTweak.exe \"{SettingsRepository.currentName}\" && \"{SettingsRepository.currentLocation}\"");
+ CommandExecutor.RunCommand($"/c taskkill /f /im \"{SettingsRepository.currentName}\" && timeout /t 2 && del \"{SettingsRepository.currentLocation}\" && ren {tempFileName} \"{SettingsRepository.currentName}\" && \"{SettingsRepository.currentLocation}\"");
};
- webClient.DownloadFileAsync(new Uri("https://github.com/Greedeks/GTweak/releases/latest/download/GTweak.exe"), "Git-GTweak.exe");
+ webClient.DownloadFileAsync(new Uri("https://github.com/Greedeks/GTweak/releases/latest/download/GTweak.exe"), tempFileName);
}
catch
{