diff --git a/Rectify11Installer/Core/Backend/Icons.cs b/Rectify11Installer/Core/Backend/Icons.cs
index 6638a7cba..f2d469ca1 100644
--- a/Rectify11Installer/Core/Backend/Icons.cs
+++ b/Rectify11Installer/Core/Backend/Icons.cs
@@ -145,6 +145,30 @@ public static bool Install(FrmWizard frm)
Variables.RestartRequired = true;
return true;
}
+
+ public static bool Uninstall()
+ {
+ Helper.SafeFileOperation(Path.Combine(Variables.r11Folder, "Rectify11.Phase2.exe"), Properties.Resources.Rectify11Phase2, Helper.OperationType.Write);
+ Helper.SafeFileOperation(Path.Combine(Variables.r11Folder, "aRun.exe"), Properties.Resources.AdvancedRun, Helper.OperationType.Write);
+ try
+ {
+ Registry.LocalMachine.OpenSubKey(@"SOFTWARE", true)
+ ?.CreateSubKey("Rectify11", true)
+ ?.SetValue("UninstallFiles", UninstallOptions.uninstIconsList.ToArray());
+
+ if (!Variables.Phase2Skip)
+ {
+ Logger.WriteLine("Executed Rectify11.Phase2.exe");
+ Helper.RunAsTI(Path.Combine(Variables.r11Folder, "Rectify11.Phase2.exe"), "/uninstall");
+ }
+ }
+ catch { }
+
+ Helper.SafeFileDeletion(Path.Combine(Variables.r11Folder, "Rectify11.Phase2.exe"));
+ Helper.SafeFileDeletion(Path.Combine(Variables.r11Folder, "aRun.exe"));
+ return true;
+ }
+
///
/// fixes 32-bit odbc shortcut icon
///
diff --git a/Rectify11Installer/Core/Backend/Themes.cs b/Rectify11Installer/Core/Backend/Themes.cs
index c579cf497..8da74c620 100644
--- a/Rectify11Installer/Core/Backend/Themes.cs
+++ b/Rectify11Installer/Core/Backend/Themes.cs
@@ -1,8 +1,11 @@
using Microsoft.VisualBasic;
+using Microsoft.Win32;
using Rectify11Installer.Win32;
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.IO;
+using static Rectify11Installer.Win32.NativeMethods;
namespace Rectify11Installer.Core
{
@@ -19,11 +22,6 @@ public static bool Install()
}
Logger.WriteLine("WriteFiles() succeeded.");
- Helper.KillProcess("micaforeveryone.exe");
- Helper.KillProcess("micafix.exe");
- Helper.KillProcess("explorerframe.exe");
- Helper.DeleteTask("mfe");
- Helper.DeleteTask("micafix");
if (Directory.Exists(Path.Combine(Variables.r11Folder, "themes")))
{
@@ -48,15 +46,7 @@ public static bool Install()
{
if (!InstallOptions.SkipMFE)
{
- if (Directory.Exists(Path.Combine(Variables.Windir, "MicaForEveryone")))
- {
- if (!Helper.SafeDirectoryDeletion(Path.Combine(Variables.Windir, "MicaForEveryone"), false))
- {
- Logger.WriteLine("Deleting " + Path.Combine(Variables.Windir, "MicaForEveryone") + " failed. ");
- return false;
- }
- }
- Directory.Move(Path.Combine(Variables.r11Folder, "Themes", "MicaForEveryone"), Path.Combine(Variables.Windir, "MicaForEveryone"));
+
InstallMfe();
Logger.WriteLine("InstallMfe() succeeded.");
}
@@ -79,14 +69,70 @@ public static bool Install()
Logger.WriteLine("══════════════════════════════════════════════");
return true;
}
+ public static bool Uninstall()
+ {
+ var s = IsArm64() ? Properties.Resources.secureux_arm64 : Properties.Resources.secureux_x64;
+ var dll = IsArm64() ? Properties.Resources.ThemeDll_arm64 : Properties.Resources.ThemeDll_x64;
+
+ if (!Helper.SafeFileOperation(Path.Combine(Variables.r11Folder, "SecureUXHelper.exe"), s, Helper.OperationType.Write))
+ return false;
+ if (!Helper.SafeFileOperation(Path.Combine(Variables.r11Folder, "ThemeDll.dll"), dll, Helper.OperationType.Write))
+ return false;
+
+ string mode = Theme.IsUsingDarkMode ? "dark.theme" : "aero.theme";
+ Process.Start(Path.Combine(Variables.Windir, "Resources", "Themes", mode));
+ string theme = Theme.IsUsingDarkMode ? "Windows (dark)" : "Windows (light)";
+ Interaction.Shell(Path.Combine(Variables.r11Folder, "SecureUXHelper.exe") + " apply " + '"' + theme + '"', AppWinStyle.Hide, true);
+
+ UninstallThemeWallpapers();
+
+ Interaction.Shell(Path.Combine(Variables.r11Folder, "SecureUXHelper.exe") + " uninstall", AppWinStyle.Hide, true);
+ Helper.SafeFileDeletion(Path.Combine(Variables.Windir, "Themetool.exe"));
+ Logger.WriteLine("Deleted " + Path.Combine(Variables.Windir, "Themetool.exe"));
+
+ UninstallCursors();
+
+ UninstallMsstyles();
+
+ Helper.SafeFileDeletion(Path.Combine(Variables.r11Folder, "SecureUXHelper.exe"));
+ Helper.SafeFileDeletion(Path.Combine(Variables.r11Folder, "ThemeDll.dll"));
+
+ UninstallMfe();
+
+ try
+ {
+ var key = Registry.ClassesRoot.OpenSubKey(@"CLSID", true);
+ key.DeleteSubKeyTree("{959E11F4-0A48-49cf-8416-FF9BC49D9656}", false);
+ key.Dispose();
+ key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel\NameSpace", true);
+ key.DeleteSubKeyTree("{959E11F4-0A48-49cf-8416-FF9BC49D9656}", false);
+ key.Dispose();
+ key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontSubstitutes", true);
+ key.SetValue("MS Shell Dlg 2", "Tahoma");
+ key.SetValue("MS Shell Dlg", "Microsoft Sans Serif");
+ key.Dispose();
+ key = Registry.CurrentUser.OpenSubKey(@"Control Panel\Desktop\WindowMetrics", true);
+ key.SetValue("MenuHeight", "-285");
+ key.SetValue("MenuWidth", "-285");
+ key.Dispose();
+ Logger.WriteLine("Remove registry entries");
+ }
+ catch { }
+
+ // nuke r11cp
+ Helper.SafeFileDeletion(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Microsoft", "Windows", "Start Menu", "Programs", "Rectify11 Control Center.lnk"));
+ Helper.SafeFileDeletion(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Rectify11 Control Center.lnk"));
+ Helper.SafeDirectoryDeletion(Path.Combine(Variables.r11Folder, "Rectify11ControlCenter"), false);
+
+ Logger.WriteLine("Deleted Rectify11 Control Center");
+ return true;
+ }
+
///
/// installs themes
///
private static bool InstallThemes()
{
- var curdir = new DirectoryInfo(Path.Combine(Variables.r11Folder, "themes", "cursors"))
- .GetDirectories("*", SearchOption.TopDirectoryOnly);
-
InstallThemeWallpapers();
// todo: remove r11cp
@@ -95,7 +141,7 @@ private static bool InstallThemes()
Interaction.Shell(Path.Combine(Variables.r11Folder, "SecureUXHelper.exe") + " install", AppWinStyle.Hide, true);
Interaction.Shell(Path.Combine(Variables.sys32Folder, "reg.exe") + " import " + Path.Combine(Variables.r11Folder, "themes", "Themes.reg"), AppWinStyle.Hide);
- InstallCursors(curdir);
+ InstallCursors();
InstallMsstyles();
return true;
}
@@ -135,29 +181,27 @@ private static void Installr11cpl()
///
private static void InstallMfe()
{
+ UninstallMfe();
+ Directory.Move(Path.Combine(Variables.r11Folder, "Themes", "MicaForEveryone"), Path.Combine(Variables.Windir, "MicaForEveryone"));
Interaction.Shell(Path.Combine(Variables.sys32Folder, "schtasks.exe") + " /create /tn mfe /xml " + Path.Combine(Variables.Windir, "MicaForEveryone", "XML", "mfe.xml"), AppWinStyle.Hide);
- if (Directory.Exists(Path.Combine(Environment.GetEnvironmentVariable("localappdata") ?? string.Empty, "Mica For Everyone")))
- {
- Directory.Delete(Path.Combine(Environment.GetEnvironmentVariable("localappdata") ?? string.Empty, "Mica For Everyone"), true);
- }
- string t = "";
- if (InstallOptions.TabbedNotMica) t = "T";
- if (InstallOptions.ThemeLight)
- {
- File.Copy(Path.Combine(Variables.Windir, "MicaForEveryone", "CONF", t + "lightrectified.conf"), Path.Combine(Variables.Windir, "MicaForEveryone", "MicaForEveryone.conf"), true);
- }
- else if (InstallOptions.ThemeDark)
+
+ string path = Path.Combine(Environment.GetEnvironmentVariable("localappdata"), "Mica For Everyone");
+ if (Directory.Exists(path))
{
- File.Copy(Path.Combine(Variables.Windir, "MicaForEveryone", "CONF", t + "darkrectified.conf"), Path.Combine(Variables.Windir, "MicaForEveryone", "MicaForEveryone.conf"), true);
+ Helper.SafeDirectoryDeletion(path, false);
}
+ string t = InstallOptions.TabbedNotMica ? "T" : "";
+ string val;
+ if (InstallOptions.ThemeLight) val = t + "lightrectified.conf";
+ else if (InstallOptions.ThemeDark) val = t + "darkrectified.conf";
else
{
- File.Copy(Path.Combine(Variables.Windir, "MicaForEveryone", "CONF", t + "black.conf"), Path.Combine(Variables.Windir, "MicaForEveryone", "MicaForEveryone.conf"), true);
- string amdorarm = "AMD";
- if (NativeMethods.IsArm64()) amdorarm = "ARM";
+ val = t + "black.conf";
+ string amdorarm = NativeMethods.IsArm64() ? "ARM" : "AMD";
Interaction.Shell(Path.Combine(Variables.sys32Folder, "schtasks.exe") + " /create /tn micafix /xml " + Path.Combine(Variables.Windir, "MicaForEveryone", "XML", "micafix" + amdorarm + "64.xml"), AppWinStyle.Hide);
}
-
+ File.Copy(Path.Combine(Variables.Windir, "MicaForEveryone", "CONF", val),
+ Path.Combine(Variables.Windir, "MicaForEveryone", "MicaForEveryone.conf"), true);
}
#region Internal
@@ -196,12 +240,18 @@ private static bool UninstallThemeWallpapers()
"img19.png",
"metal.png"
};
- var files = Directory.GetFiles(Path.Combine(Variables.Windir, "web", "wallpaper", "Rectified"));
+ string path = Path.Combine(Variables.Windir, "web", "wallpaper", "Rectified");
+ var files = Directory.GetFiles(path);
for (int j = 0; j < files.Length; j++)
{
if (!wallpapers.Contains(Path.GetFileName(files[j])))
Helper.SafeFileDeletion(files[j]);
}
+ if (Directory.GetFiles(path).Length == 0)
+ {
+ Helper.SafeDirectoryDeletion(path, false);
+ Logger.WriteLine("Deleted " + path);
+ }
Logger.WriteLine("Deleted old wallpapers");
}
catch (Exception ex)
@@ -211,9 +261,12 @@ private static bool UninstallThemeWallpapers()
}
return true;
}
- private static bool InstallCursors(DirectoryInfo[] curdir)
+ private static bool InstallCursors()
{
UninstallCursors();
+ var curdir = new DirectoryInfo(Path.Combine(Variables.r11Folder, "themes", "cursors"))
+ .GetDirectories("*", SearchOption.TopDirectoryOnly);
+
for (var i = 0; i < curdir.Length; i++)
{
try
@@ -248,20 +301,38 @@ private static bool UninstallCursors()
}
private static bool UninstallMsstyles()
{
- if (Directory.Exists(Path.Combine(Variables.Windir, "Resources", "Themes", "Rectified")))
+ // .theme files
+ List themefiles = new()
{
- try
- {
- Helper.SafeDirectoryDeletion(Path.Combine(Variables.Windir, "Resources", "Themes", "Rectified"), false);
- }
- catch (Exception ex)
+ "black.theme",
+ "darkcolorized.theme",
+ "darkrectified.theme",
+ "lightrectified.theme"
+ };
+ try
+ {
+ for (int i = 0; i < themefiles.Count; i++)
{
- Logger.WriteLine("Error deleting " + Path.Combine(Variables.Windir, "Resources", "Themes", "Rectified") + ex.Message + Environment.NewLine + ex.StackTrace + Environment.NewLine);
- return false;
+ Helper.SafeFileDeletion(Path.Combine(Variables.Windir, "Resources", "Themes", themefiles[i]));
}
- return true;
+ Logger.WriteLine("Deleted themes");
}
- return false;
+ catch (Exception ex)
+ {
+ Logger.WriteLine("Error deleting themes", ex);
+ }
+
+ // msstyles
+ try
+ {
+ Helper.SafeDirectoryDeletion(Path.Combine(Variables.Windir, "Resources", "Themes", "Rectified"), false);
+ }
+ catch (Exception ex)
+ {
+ Logger.WriteLine("Error deleting " + Path.Combine(Variables.Windir, "Resources", "Themes", "Rectified") + ex.Message + Environment.NewLine + ex.StackTrace + Environment.NewLine);
+ return false;
+ }
+ return true;
}
private static bool InstallMsstyles()
{
@@ -293,6 +364,27 @@ private static bool InstallMsstyles()
File.Delete(Path.Combine(Variables.r11Folder, "aRun1.exe"));
return true;
}
+ private static bool UninstallMfe()
+ {
+ try
+ {
+ Helper.KillProcess("micaforeveryone.exe");
+ Helper.KillProcess("micafix.exe");
+ Helper.KillProcess("explorerframe.exe");
+ Helper.DeleteTask("mfe");
+ Helper.DeleteTask("micafix");
+ if (Directory.Exists(Path.Combine(Variables.Windir, "MicaForEveryone")))
+ {
+ if (!Helper.SafeDirectoryDeletion(Path.Combine(Variables.Windir, "MicaForEveryone"), false))
+ {
+ Logger.WriteLine("Deleting " + Path.Combine(Variables.Windir, "MicaForEveryone") + " failed. ");
+ return false;
+ }
+ }
+ return true;
+ }
+ catch { return false; }
+ }
#endregion
}
}
diff --git a/Rectify11Installer/Core/Backend/Uninstaller.cs b/Rectify11Installer/Core/Backend/Uninstaller.cs
index 6f35073e6..7cfd45915 100644
--- a/Rectify11Installer/Core/Backend/Uninstaller.cs
+++ b/Rectify11Installer/Core/Backend/Uninstaller.cs
@@ -20,7 +20,7 @@ public async Task Uninstall(FrmWizard frm)
Logger.WriteLine("Uninstalling icons");
Logger.WriteLine("──────────────────");
frm.InstallerProgress = "Uninstalling icons";
- await Task.Run(() => UninstallIcons());
+ await Task.Run(() => Icons.Uninstall());
Variables.RestartRequired = true;
Console.WriteLine("══════════════════════════════════════════════");
}
@@ -29,7 +29,7 @@ public async Task Uninstall(FrmWizard frm)
Logger.WriteLine("Uninstalling themes");
Logger.WriteLine("───────────────────");
frm.InstallerProgress = "Uninstalling themes";
- await Task.Run(() => UninstallThemes());
+ await Task.Run(() => Themes.Uninstall());
Variables.RestartRequired = true;
Console.WriteLine("══════════════════════════════════════════════");
}
@@ -92,316 +92,7 @@ public async Task Uninstall(FrmWizard frm)
if (!Variables.RestartRequired) frm.InstallerProgress = "Done, you can close this window";
return true;
}
- private async Task UninstallIcons()
- {
- using var reg = Registry.LocalMachine.OpenSubKey(@"SOFTWARE", true)?.CreateSubKey("Rectify11", true);
- File.WriteAllBytes(Path.Combine(Variables.r11Folder, "Rectify11.Phase2.exe"), Properties.Resources.Rectify11Phase2);
- Logger.WriteLine("Wrote Rectify11.Phase2.exe");
- File.WriteAllBytes(Path.Combine(Variables.r11Folder, "aRun.exe"), Properties.Resources.AdvancedRun);
- Logger.WriteLine("Wrote aRun.exe");
- try
- {
- reg.SetValue("UninstallFiles", UninstallOptions.uninstIconsList.ToArray());
- if (!Variables.Phase2Skip)
- {
- Logger.WriteLine("Executed Rectify11.Phase2.exe");
- await Task.Run(() => Interaction.Shell(Path.Combine(Variables.r11Folder, "aRun.exe")
- + " /EXEFilename " + '"' + Path.Combine(Variables.r11Folder, "Rectify11.Phase2.exe") + '"'
- + " /CommandLine " + "\'" + "/uninstall" + "\'"
- + " /WaitProcess 1 /RunAs 8 /Run", AppWinStyle.NormalFocus, true));
- }
- }
- catch { }
- try
- {
- File.Delete(Path.Combine(Variables.r11Folder, "Rectify11.Phase2.exe"));
- }
- catch
- {
- string name = Path.GetRandomFileName();
- File.Move(Path.Combine(Variables.r11Folder, "Rectify11.Phase2.exe"), Path.Combine(Path.GetTempPath(), name));
- MoveFileEx(Path.Combine(Path.GetTempPath(), name), null, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT);
- }
- try
- {
- File.Delete(Path.Combine(Variables.r11Folder, "aRun.exe"));
- }
- catch
- {
- string name = Path.GetRandomFileName();
- File.Move(Path.Combine(Variables.r11Folder, "aRun.exe"), Path.Combine(Path.GetTempPath(), name));
- MoveFileEx(Path.Combine(Path.GetTempPath(), name), null, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT);
- }
- return true;
- }
- private async Task UninstallThemes()
- {
- await Task.Run(() => Interaction.Shell(Path.Combine(Variables.sys32Folder, "taskkill.exe") + " /f /im micaforeveryone.exe", AppWinStyle.Hide, true));
- await Task.Run(() => Interaction.Shell(Path.Combine(Variables.sys32Folder, "taskkill.exe") + " /f /im micafix.exe", AppWinStyle.Hide, true));
- await Task.Run(() => Interaction.Shell(Path.Combine(Variables.sys32Folder, "taskkill.exe") + " /f /im explorerframe.exe", AppWinStyle.Hide, true));
- await Task.Run(() => Interaction.Shell(Path.Combine(Variables.sys32Folder, "schtasks.exe") + " /delete /f /tn mfe", AppWinStyle.Hide));
- await Task.Run(() => Interaction.Shell(Path.Combine(Variables.sys32Folder, "schtasks.exe") + " /delete /f /tn micafix", AppWinStyle.Hide));
- var s = Properties.Resources.secureux_x64;
- var dll = Properties.Resources.ThemeDll_x64;
- if (NativeMethods.IsArm64())
- {
- s = Properties.Resources.secureux_arm64;
- dll = Properties.Resources.secureux_arm64;
- }
-
- try
- {
- File.WriteAllBytes(Path.Combine(Variables.r11Folder, "SecureUXHelper.exe"), s);
- Logger.WriteLine("Wrote SecureUXHelper.exe");
- }
- catch { }
- try
- {
- File.WriteAllBytes(Path.Combine(Variables.r11Folder, "ThemeDll.dll"), dll);
- Logger.WriteLine("Wrote ThemeDll.dll");
- }
- catch { }
- if (Theme.IsUsingDarkMode)
- {
- await Task.Run(() => Process.Start(Path.Combine(Variables.Windir, "Resources", "Themes", "dark.theme")));
- await Task.Run(() => Interaction.Shell(Path.Combine(Variables.r11Folder, "SecureUXHelper.exe") + " apply " + '"' + "Windows (dark)" + '"', AppWinStyle.Hide, true));
- }
- else
- {
- await Task.Run(() => Process.Start(Path.Combine(Variables.Windir, "Resources", "Themes", "aero.theme")));
- await Task.Run(() => Interaction.Shell(Path.Combine(Variables.r11Folder, "SecureUXHelper.exe") + " apply " + '"' + "Windows (light)" + '"', AppWinStyle.Hide, true));
- }
- if (Directory.Exists(Path.Combine(Variables.Windir, "web", "wallpaper", "Rectified")))
- {
- List wallpapers = new List
- {
- "cosmic.png",
- "img0.png",
- "img19.png",
- "metal.png"
- };
- for (int i = 0; i < wallpapers.Count; i++)
- {
- if (File.Exists(Path.Combine(Variables.Windir, "web", "Wallpaper", "Rectified", wallpapers[i])))
- {
- try
- {
- File.Delete(Path.Combine(Variables.Windir, "web", "Wallpaper", "Rectified", wallpapers[i]));
- }
- catch
- {
- string name = Path.GetRandomFileName();
- File.Move(Path.Combine(Variables.Windir, "web", "Wallpaper", "Rectified", wallpapers[i]), Path.Combine(Path.GetTempPath(), name));
- MoveFileEx(Path.Combine(Path.GetTempPath(), name), null, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT);
- }
- Logger.WriteLine("Deleted " + Path.Combine(Variables.Windir, "web", "Wallpaper", "Rectified", wallpapers[i]));
- }
- }
- if (Directory.GetFiles(Path.Combine(Variables.Windir, "web", "wallpaper", "Rectified")).Length == 0)
- {
- try
- {
- Directory.Delete(Path.Combine(Variables.Windir, "web", "wallpaper", "Rectified"), true);
- }
- catch
- {
- string name = Path.GetRandomFileName();
- Directory.Move(Path.Combine(Variables.Windir, "web", "wallpaper", "Rectified"), Path.Combine(Path.GetTempPath(), name));
- MoveFileEx(Path.Combine(Path.GetTempPath(), name), null, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT);
- }
- Logger.WriteLine("Deleted " + Path.Combine(Variables.Windir, "web", "wallpaper", "Rectified"));
- }
- }
- await Task.Run(() => Interaction.Shell(Path.Combine(Variables.r11Folder, "SecureUXHelper.exe") + " uninstall", AppWinStyle.Hide, true));
- if (File.Exists(Path.Combine(Variables.Windir, "Themetool.exe")))
- {
- try
- {
- File.Delete(Path.Combine(Variables.Windir, "Themetool.exe"));
- }
- catch
- {
- string name = Path.GetRandomFileName();
- File.Move(Path.Combine(Variables.Windir, "Themetool.exe"), Path.Combine(Path.GetTempPath(), name));
- MoveFileEx(Path.Combine(Path.GetTempPath(), name), null, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT);
- }
- Logger.WriteLine("Deleted " + Path.Combine(Variables.Windir, "Themetool.exe"));
-
- }
- if (Directory.Exists(Path.Combine(Variables.Windir, "cursors", "WindowsRectified")))
- {
- try
- {
- Directory.Delete(Path.Combine(Variables.Windir, "cursors", "WindowsRectified"), true);
- }
- catch
- {
- string name = Path.GetTempPath();
- Directory.Move(Path.Combine(Variables.Windir, "cursors", "WindowsRectified"), Path.Combine(Path.GetTempPath(), name));
- var fil = Directory.GetFiles(Path.Combine(Path.GetTempPath(), name));
- for (int i = 0; i < fil.Length; i++)
- {
- MoveFileEx(fil[i], null, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT);
- }
- MoveFileEx(Path.Combine(Path.GetTempPath(), name), null, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT);
- }
- Logger.WriteLine("Deleted " + Path.Combine(Variables.Windir, "cursors", "WindowsRectified"));
- }
- if (Directory.Exists(Path.Combine(Variables.Windir, "cursors", "WindowsRectifiedDark")))
- {
- try
- {
- Directory.Delete(Path.Combine(Variables.Windir, "cursors", "WindowsRectifiedDark"), true);
- }
- catch
- {
- string name = Path.GetTempPath();
- Directory.Move(Path.Combine(Variables.Windir, "cursors", "WindowsRectifiedDark"), Path.Combine(Path.GetTempPath(), name));
- var fil = Directory.GetFiles(Path.Combine(Path.GetTempPath(), name));
- for (int i = 0; i < fil.Length; i++)
- {
- MoveFileEx(fil[i], null, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT);
- }
- MoveFileEx(Path.Combine(Path.GetTempPath(), name), null, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT);
- }
- Logger.WriteLine("Deleted " + Path.Combine(Variables.Windir, "cursors", "WindowsRectified"));
- }
- List themefiles = new List
- {
- "black.theme",
- "darkcolorized.theme",
- "darkrectified.theme",
- "lightrectified.theme"
- };
- for (int i = 0; i < themefiles.Count; i++)
- {
- if (File.Exists(Path.Combine(Variables.Windir, "Resources", "Themes", themefiles[i])))
- {
- try
- {
- File.Delete(Path.Combine(Variables.Windir, "Resources", "Themes", themefiles[i]));
- }
- catch
- {
- string name = Path.GetRandomFileName();
- File.Move(Path.Combine(Variables.Windir, "Resources", "Themes", themefiles[i]), Path.Combine(Path.GetTempPath(), name));
- MoveFileEx(Path.Combine(Path.GetTempPath(), name), null, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT);
- }
- Logger.WriteLine("Deleted " + Path.Combine(Variables.Windir, "Resources", "Themes", themefiles[i]));
- }
- }
- if (Directory.Exists(Path.Combine(Variables.Windir, "Resources", "Themes", "Rectified")))
- {
- string name = Path.GetRandomFileName();
- Directory.Move(Path.Combine(Variables.Windir, "Resources", "Themes", "Rectified"), Path.Combine(Path.GetTempPath(), name));
- if (Directory.Exists(Path.Combine(Path.GetTempPath(), name, "Shell")))
- {
- try
- {
- Directory.Delete(Path.Combine(Path.GetTempPath(), name, "Shell"), true);
- }
- catch { }
- }
- var files = Directory.GetFiles(Path.Combine(Path.GetTempPath(), name));
- for (int j = 0; j < files.Length; j++)
- {
- MoveFileEx(files[j], null, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT);
- }
- MoveFileEx(Path.Combine(Path.GetTempPath(), name), null, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT);
- Logger.WriteLine("Deleted msstyle");
- }
- try
- {
- File.Delete(Path.Combine(Variables.r11Folder, "SecureUXHelper.exe"));
- }
- catch
- {
- MoveFileEx(Path.Combine(Variables.r11Folder, "SecureUXHelper.exe"), null, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT);
- }
-
- try
- {
- File.Delete(Path.Combine(Variables.r11Folder, "ThemeDll.dll"));
- }
- catch
- {
- MoveFileEx(Path.Combine(Variables.r11Folder, "ThemeDll.dll"), null, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT);
- }
- // waow
- if (Directory.Exists(Path.Combine(Variables.Windir, "MicaForEveryone")))
- {
- try
- {
- Directory.Delete(Path.Combine(Variables.Windir, "MicaForEveryone"), true);
- }
- catch
- {
- string name = Path.GetRandomFileName();
- Directory.Move(Path.Combine(Variables.Windir, "MicaForEveryone"), Path.Combine(Path.GetTempPath(), name));
- }
- Logger.WriteLine("Deleted MicaForEveryone");
- }
- try
- {
- var key = Registry.ClassesRoot.OpenSubKey(@"CLSID", true);
- key.DeleteSubKeyTree("{959E11F4-0A48-49cf-8416-FF9BC49D9656}", false);
- key.Dispose();
- key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel\NameSpace", true);
- key.DeleteSubKeyTree("{959E11F4-0A48-49cf-8416-FF9BC49D9656}", false);
- key.Dispose();
- key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontSubstitutes", true);
- key.SetValue("MS Shell Dlg 2", "Tahoma");
- key.SetValue("MS Shell Dlg", "Microsoft Sans Serif");
- key.Dispose();
- key = Registry.CurrentUser.OpenSubKey(@"Control Panel\Desktop\WindowMetrics", true);
- key.SetValue("MenuHeight", "-285");
- key.SetValue("MenuWidth", "-285");
- key.Dispose();
- Logger.WriteLine("Remove registry entries");
- }
- catch { }
- // nuke r11cp
- if (File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Microsoft", "Windows", "Start Menu", "Programs", "Rectify11 Control Center.lnk")))
- {
- try
- {
- File.Delete(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Microsoft", "Windows", "Start Menu", "Programs", "Rectify11 Control Center.lnk"));
- }
- catch
- {
- MoveFileEx(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Microsoft", "Windows", "Start Menu", "Programs", "Rectify11 Control Center.lnk"), null, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT);
- }
- }
- if (File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Rectify11 Control Center.lnk")))
- {
- try
- {
- File.Delete(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Rectify11 Control Center.lnk"));
- }
- catch { MoveFileEx(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Rectify11 Control Center.lnk"), null, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT); }
- }
- if (Directory.Exists(Path.Combine(Variables.r11Folder, "Rectify11ControlCenter")))
- {
- try
- {
- Directory.Delete(Path.Combine(Variables.r11Folder, "Rectify11ControlCenter"), true);
- }
- catch
- {
- string name = Path.GetRandomFileName();
- Directory.Move(Path.Combine(Variables.r11Folder, "Rectify11ControlCenter"), Path.Combine(Path.GetTempPath(), name));
- var fil = Directory.GetFiles(Path.Combine(Path.GetTempPath(), name));
- for (int i = 0; i < fil.Length; i++)
- {
- MoveFileEx(fil[i], null, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT);
- }
- MoveFileEx(Path.Combine(Path.GetTempPath(), name), null, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT);
- }
- }
- Logger.WriteLine("Deleted Rectify11 Control Center");
- return true;
- }
private async Task UninstallExtras()
{
for (int i = 0; i < UninstallOptions.uninstExtrasList.Count; i++)
diff --git a/Rectify11Installer/Core/Helpers.cs b/Rectify11Installer/Core/Helpers.cs
index a19ef4f79..e83dcad82 100644
--- a/Rectify11Installer/Core/Helpers.cs
+++ b/Rectify11Installer/Core/Helpers.cs
@@ -333,6 +333,13 @@ public static bool SafeDirectoryDeletion(string path, bool ischild)
return false;
}
}
+ public static void RunAsTI(string file,string param)
+ {
+ Interaction.Shell(Path.Combine(Variables.r11Folder, "aRun.exe")
+ + " /EXEFilename " + '"' + file + '"'
+ + " /CommandLine " + "\'" + param + "\'"
+ + " /WaitProcess 1 /RunAs 8 /Run", AppWinStyle.NormalFocus, true);
+ }
#endregion
#region Private Methods
private static bool RebootRequired()
diff --git a/Rectify11Installer/Pages/ProgressPage.cs b/Rectify11Installer/Pages/ProgressPage.cs
index d9fc6e2fe..087709f4a 100644
--- a/Rectify11Installer/Pages/ProgressPage.cs
+++ b/Rectify11Installer/Pages/ProgressPage.cs
@@ -96,7 +96,7 @@ private async void NavigationHelper_OnNavigate(object sender, EventArgs e)
RectifyPages.ProgressPage.Start();
NativeMethods.SetCloseButton(frmwiz, false);
Uninstaller uninstaller = new();
- await uninstaller.Uninstall(frmwiz);
+ await Task.Run(() => uninstaller.Uninstall(frmwiz));
if (Variables.RestartRequired)
{
NativeMethods.SetCloseButton(frmwiz, false);