Skip to content

Commit

Permalink
improve installation process
Browse files Browse the repository at this point in the history
  • Loading branch information
MishaProductions committed May 30, 2024
1 parent 907c41c commit 1a4ba88
Show file tree
Hide file tree
Showing 17 changed files with 531 additions and 209 deletions.
4 changes: 2 additions & 2 deletions Rectify11.Phase2/Rectify11.Phase2.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
<Company>Rectify11</Company>
<Product>Rectify11Installer.</Product>
<Copyright>Copyright © 2024 The Rectify11 Team</Copyright>
<AssemblyVersion>3.2.68</AssemblyVersion>
<FileVersion>3.2.68</FileVersion>
<AssemblyVersion>3.2.68.2</AssemblyVersion>
<FileVersion>3.2.68.2</FileVersion>
<NeutralLanguage>en</NeutralLanguage>
</PropertyGroup>
<ItemGroup>
Expand Down
47 changes: 14 additions & 33 deletions Rectify11Installer/Core/Backend/Extras.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.VisualBasic;
using Rectify11Installer.Win32;
using System;
using System.Collections.Generic;
using System.Diagnostics;
Expand Down Expand Up @@ -44,15 +45,13 @@ public static bool Install(FrmWizard frm)
InstallGadgets();
Helper.SafeDirectoryDeletion(Path.Combine(Variables.r11Folder, "extras", "GadgetPack"), false);
}
if (InstallOptions.InstallShell)
{
frm.InstallerProgress = "Installing extras: Enhanced context menu";
frm.InstallerProgress = "Installing extras: Enhanced context menu";

InstallShell();
InstallShell();

Helper.SafeDirectoryDeletion(Path.Combine(Variables.r11Folder, "extras", "Nilesoft"), false);
Helper.SafeDirectoryDeletion(Path.Combine(Variables.r11Folder, "extras", "NilesoftArm64"), false);

Helper.SafeDirectoryDeletion(Path.Combine(Variables.r11Folder, "extras", "Nilesoft"), false);
Helper.SafeDirectoryDeletion(Path.Combine(Variables.r11Folder, "extras", "NilesoftArm64"), false);
}
if (InstallOptions.userAvatars)
{
frm.InstallerProgress = "Installing extras: User avatars";
Expand Down Expand Up @@ -236,38 +235,20 @@ private static bool InstallShell()
string s = "";
if (IsArm64()) s = "Arm64";
Directory.Move(Path.Combine(Variables.r11Folder, "extras", "nilesoft" + s), Path.Combine(Variables.Windir, "nilesoft"));
ProcessStartInfo shlinfo2 = new()
{
FileName = Path.Combine(Variables.Windir, "nilesoft", "shell.exe"),
WindowStyle = ProcessWindowStyle.Hidden,
Arguments = " -r"
};
int num = InstallOptions.CMenuStyle;
if (num == 1 || num == 2)
{
string text = (string)Properties.Resources.ResourceManager.GetObject("config" + num);
File.WriteAllText(Path.Combine(Variables.Windir, "nilesoft", "shell.nss"), text);
var shlInstproc2 = Process.Start(shlinfo2);
shlInstproc2.WaitForExit();
}
if (num == 3 || num == 4)
{
Process.Start(Path.Combine(Variables.sys32Folder, "reg.exe"), " add \"HKCU\\Software\\Classes\\CLSID\\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\\InprocServer32\" /f /ve");
}
if (num == 4)

Logger.WriteLine("Setting menu type: " + InstallOptions.MenuStyle);
nint hr = RectifyThemeUtil.Utility.SetCurrentMenuByIndex((int)InstallOptions.MenuStyle);
if (hr != 0)
{
using ShellLink shortcut = new();
shortcut.Target = Path.Combine(Variables.Windir, "nilesoft", "AcrylicMenus", "AcrylicMenusLoader.exe");
shortcut.WorkingDirectory = @"%windir%\nilesoft\AcrylicMenus";
shortcut.DisplayMode = ShellLink.LinkDisplayMode.edmNormal;
shortcut.Save(Path.Combine(GetFolderPath(SpecialFolder.CommonStartMenu), "programs", "startup", "acrylmenu.lnk"));
Logger.WriteLine("FAILED TO UPDATE MENU CONFIG: " + hr);
}
if (!Variables.RestartRequired)

if (!Variables.RestartRequired && InstallOptions.MenuStyle != MenuStyles.Windows11Default)
{
Interaction.Shell(Path.Combine(Variables.sys32Folder, "taskkill.exe") + " /f /im explorer.exe", AppWinStyle.Hide, true);
Interaction.Shell(Path.Combine(Variables.Windir, "explorer.exe"), AppWinStyle.NormalFocus);
Thread.Sleep(3000);
if (num == 4) Process.Start(Path.Combine(GetFolderPath(SpecialFolder.CommonStartMenu), "programs", "startup", "acrylmenu.lnk"));
if (InstallOptions.MenuStyle == MenuStyles.AcrylicMenu) Process.Start(Path.Combine(GetFolderPath(SpecialFolder.CommonStartMenu), "programs", "startup", "acrylmenu.lnk"));
}

Logger.WriteLine("InstallShell() succeeded.");
Expand Down
2 changes: 1 addition & 1 deletion Rectify11Installer/Core/Backend/Installer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ private void InstallChangelogApp()
var key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);
key?.SetValue("RectifyStart", Path.Combine(Variables.r11Folder, "RectifyStart.exe"), RegistryValueKind.String);
key.Close();
}
}
#endregion
}
}
46 changes: 15 additions & 31 deletions Rectify11Installer/Core/Backend/Themes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,15 @@ public static bool Install()
{
File.WriteAllBytes(Path.Combine(Variables.r11Folder, "Rectify11TrayTool.exe"), Properties.Resources.Rectify11TrayTool);
}
catch(Exception ex)
catch (Exception ex)
{
Logger.WriteLine("Failed to copy tray utility: "+ex.Message);
Logger.WriteLine("Failed to copy tray utility: " + ex.Message);
}

try
{
if (!InstallOptions.SkipMFE)
{
InstallMfe();
Logger.WriteLine("InstallMfe() succeeded.");
}
InstallMfe();
Logger.WriteLine("InstallMfe() succeeded.");
}
catch (Exception ex)
{
Expand Down Expand Up @@ -157,7 +154,7 @@ public static bool Uninstall()
catch { }

UninstallR11Cpl();
Logger.WriteLine("Deleted Rectify11 Control Center.");
Logger.WriteLine("Deleted Rectify11 Control Panel");

Process.Start(Path.Combine(Variables.sys32Folder, "reg.exe"), @" ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide /v PreferExternalManifest /t REG_DWORD /d 0 /f");
Helper.SafeFileDeletion(Path.Combine(Variables.sys32Folder, "mmc.exe.manifest"));
Expand Down Expand Up @@ -186,7 +183,6 @@ private static bool InstallThemes()
Path.Combine(Variables.r11Folder, "themes", "ThemeTool.exe"),
Path.Combine(Variables.Windir, "ThemeTool.exe"),
Helper.OperationType.Copy);

Logger.WriteLine("Copied Themetool.");
nint hr = 0;
try
Expand Down Expand Up @@ -339,28 +335,16 @@ private static void InstallMfe()
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, true);

// Remove any old configuraion
string path = Path.Combine(Environment.GetEnvironmentVariable("localappdata"), "Mica For Everyone");
Helper.SafeDirectoryDeletion(path, false);
string t = InstallOptions.TabbedNotMica ? "T" : "";
string val = "";

// TODO: Use CRectifyUtil

if (InstallOptions.ThemeLight) val = t + "lightrectified.conf";
else if (InstallOptions.ThemeDark) val = t + "darkrectified.conf";
else if (InstallOptions.ThemePDark) val = t + "darkrectified.conf";
else if (InstallOptions.ThemeBlack)
{
val = t + "black.conf";
string amdorarm = NativeMethods.IsArm64() ? "ARM" : "AMD";
Interaction.Shell(Path.Combine(Variables.sys32Folder, "schtasks.exe") + " /create /tn mfefix /xml " + Path.Combine(Variables.Windir, "MicaForEveryone", "XML", "micafix" + amdorarm + "64.xml"), AppWinStyle.Hide, true);
}

if (!string.IsNullOrWhiteSpace(val))
{
File.Copy(Path.Combine(Variables.Windir, "MicaForEveryone", "CONF", val),
Path.Combine(Variables.Windir, "MicaForEveryone", "MicaForEveryone.conf"), true);
}
// Enable MFE
bool bEnabled = InstallOptions.EnableMicaEffect;
bool bTabbed = InstallOptions.UseTabbedInsteadOfMica;
Console.WriteLine("Installing MFE: bEnabled: " + bEnabled + ",bTabbed: " + bTabbed);
RectifyThemeUtil.Utility.SetMicaForEveryoneEnabled(ref bEnabled, ref bTabbed);
}

#region Internal
Expand Down Expand Up @@ -564,22 +548,22 @@ private static void ApplyScheme()
// to ensure that the UxTheme patcher is running.
if (InstallOptions.ThemeLight)
{
Process.Start(Path.Combine(Variables.Windir, "Resources", "Themes", "lightrectified.theme"));
Helper.RunShellExec(Path.Combine(Variables.Windir, "Resources", "Themes", "lightrectified.theme"));
config.SetValue("ApplyThemeOnNextRun", "Rectify11 light theme");
}
else if (InstallOptions.ThemeDark)
{
Process.Start(Path.Combine(Variables.Windir, "Resources", "Themes", "darkrectified.theme"));
Helper.RunShellExec(Path.Combine(Variables.Windir, "Resources", "Themes", "darkrectified.theme"));
config.SetValue("ApplyThemeOnNextRun", "Rectify11 dark theme");
}
else if (InstallOptions.ThemePDark)
{
Process.Start(Path.Combine(Variables.Windir, "Resources", "Themes", "darkpartial.theme"));
Helper.RunShellExec(Path.Combine(Variables.Windir, "Resources", "Themes", "darkpartial.theme"));
config.SetValue("ApplyThemeOnNextRun", "Rectify11 partial dark theme");
}
else
{
Process.Start(Path.Combine(Variables.Windir, "Resources", "Themes", "black.theme"));
Helper.RunShellExec(Path.Combine(Variables.Windir, "Resources", "Themes", "black.theme"));
config.SetValue("ApplyThemeOnNextRun", "Rectify11 Dark theme with Mica");
}

Expand Down
8 changes: 4 additions & 4 deletions Rectify11Installer/Core/Backend/Uninstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public bool Uninstall(FrmWizard frm)
{
Logger.WriteLine("Uninstalling icons");
Logger.WriteLine("──────────────────");
frm.InstallerProgress = Rectify11Installer.Strings.Rectify11.uninstallingIcons;
frm.InstallerProgress = Strings.Rectify11.uninstallingIcons;
if (!Icons.Uninstall()) return false;
Variables.RestartRequired = true;
Console.WriteLine("══════════════════════════════════════════════");
Expand All @@ -21,7 +21,7 @@ public bool Uninstall(FrmWizard frm)
{
Logger.WriteLine("Uninstalling themes");
Logger.WriteLine("───────────────────");
frm.InstallerProgress = Rectify11Installer.Strings.Rectify11.uninstallingThemes;
frm.InstallerProgress = Strings.Rectify11.uninstallingThemes;
if (!Themes.Uninstall()) return false;
Variables.RestartRequired = true;
Console.WriteLine("══════════════════════════════════════════════");
Expand All @@ -30,7 +30,7 @@ public bool Uninstall(FrmWizard frm)
{
Logger.WriteLine("Uninstalling extras");
Logger.WriteLine("───────────────────");
frm.InstallerProgress = Rectify11Installer.Strings.Rectify11.uninstallingExtras;
frm.InstallerProgress = Strings.Rectify11.uninstallingExtras;
if (!Extras.Uninstall()) return false;
Console.WriteLine("══════════════════════════════════════════════");
}
Expand Down Expand Up @@ -75,7 +75,7 @@ public bool Uninstall(FrmWizard frm)
using var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", true);
key.DeleteSubKey("Rectify11", false);
}
if (!Variables.RestartRequired) frm.InstallerProgress = Rectify11Installer.Strings.Rectify11.doneYouCanClose;
if (!Variables.RestartRequired) frm.InstallerProgress = Strings.Rectify11.doneYouCanClose;
return true;
}
}
Expand Down
14 changes: 11 additions & 3 deletions Rectify11Installer/Core/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -473,10 +473,10 @@ public class InstallOptions
public static bool ThemePDark { get; set; }
public static bool InstallShell { get; set; }
public static bool InstallSounds { get; set; }
public static bool SkipMFE { get; set; }
public static bool TabbedNotMica { get; set; }
public static bool EnableMicaEffect { get; set; } = false;
public static bool UseTabbedInsteadOfMica { get; set; } = false;
public static bool userAvatars { get; set; }
public static int CMenuStyle = 1;
public static MenuStyles MenuStyle = MenuStyles.Windows11Default;
public static List<string> iconsList = new();
public static List<string> origList = new();

Expand All @@ -492,6 +492,14 @@ public static bool InstallExtras()
|| userAvatars;
}
}
public enum MenuStyles
{
Windows11Default = 0,
NilesoftSmall = 1,
NilesoftShellAll = 2,
ClassicMenu = 3,
AcrylicMenu = 4
}
public class UninstallOptions
{
// does nothing
Expand Down
2 changes: 1 addition & 1 deletion Rectify11Installer/Pages/CMenuPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private Controls.DarkAwareRadioButton getButton(int num)
string a = "L";
if (Theme.IsUsingDarkMode) a = "D";
PrevImg.Image = (Bitmap)Properties.Resources.ResourceManager.GetObject("_" + num + a);
InstallOptions.CMenuStyle = num;
InstallOptions.MenuStyle = (MenuStyles)num;
}
return rad;
}
Expand Down
Loading

0 comments on commit 1a4ba88

Please sign in to comment.