diff --git a/Rectify11.Phase2/Helper.cs b/Rectify11.Phase2/Helper.cs index 8b6dae5e4..1ab3e2e36 100644 --- a/Rectify11.Phase2/Helper.cs +++ b/Rectify11.Phase2/Helper.cs @@ -32,7 +32,7 @@ public static bool SafeFileDeletion(string path) string name = Path.GetRandomFileName(); string tmpPath = Path.Combine(Path.GetTempPath(), name); File.Move(path, tmpPath); - Program.MoveFileEx(tmpPath, null, Program.MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT); + MoveFileEx(tmpPath, null, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT); } return true; } @@ -57,11 +57,25 @@ public static bool SafeFileCopy(string file) return false; } } + public static bool SafeFileCopy(string src, string dest) + { + try + { + if (!SafeFileDeletion(dest)) return false; + File.Copy(src, dest, true); + return true; + } + catch + { + return false; + } + } + public static void ImportReg(string path) { try { - Interaction.Shell(Path.Combine(Variables.sys32Folder, "reg.exe") + " import " + path, AppWinStyle.Hide); + Interaction.Shell(Path.Combine(Variables.sys32Folder, "reg.exe") + " import " + path, AppWinStyle.Hide, true); } catch (Exception ex) { diff --git a/Rectify11.Phase2/Program.cs b/Rectify11.Phase2/Program.cs index 091409544..b6d49f4d5 100644 --- a/Rectify11.Phase2/Program.cs +++ b/Rectify11.Phase2/Program.cs @@ -384,29 +384,37 @@ private static void Main(string[] args) private static void InstallFonts() { - // aaaaaaaaaaaa - var MarlettDest = Path.Combine(Variables.windir, "Fonts", "marlett.ttf"); - var MarlettBackupDest = Path.Combine(Variables.windir, "Fonts", "marlett.ttf.backup"); - var marlett = Path.Combine(Variables.r11Files, "marlett.ttf"); - File.Move(MarlettDest, MarlettBackupDest); - File.Copy(marlett, MarlettDest, true); + try + { + // aaaaaaaaaaaa + var MarlettDest = Path.Combine(Variables.windir, "Fonts", "marlett.ttf"); + var MarlettBackupDest = Path.Combine(Variables.windir, "Fonts", "marlett.ttf.backup"); + var marlett = Path.Combine(Variables.r11Files, "marlett.ttf"); - var BackIconsDest = Path.Combine(Variables.windir, "Fonts", "BackIcons.ttf"); - var backicons = Path.Combine(Variables.r11Files, "BackIcons.ttf"); - File.Copy(backicons, BackIconsDest, true); - Helper.ImportReg(Path.Combine(Variables.r11Files, "backicons.reg")); + if (!File.Exists(MarlettBackupDest)) File.Move(MarlettDest, MarlettBackupDest); + SafeFileCopy(marlett, MarlettDest); - if (Environment.OSVersion.Version.Build <= 21996) - { - var SegoeIconsDest = Path.Combine(Variables.windir, "Fonts", "SegoeIcons.ttf"); - var segoeicons = Path.Combine(Variables.r11Files, "SegoeIcons.ttf"); - File.Copy(segoeicons, SegoeIconsDest, true); - Helper.ImportReg(Path.Combine(Variables.r11Files, "segoeicons.reg")); + var BackIconsDest = Path.Combine(Variables.windir, "Fonts", "BackIcons.ttf"); + var backicons = Path.Combine(Variables.r11Files, "BackIcons.ttf"); + SafeFileCopy(backicons, BackIconsDest); + ImportReg(Path.Combine(Variables.r11Files, "backicons.reg")); + + if (Environment.OSVersion.Version.Build <= 21996) + { + var SegoeIconsDest = Path.Combine(Variables.windir, "Fonts", "SegoeIcons.ttf"); + var segoeicons = Path.Combine(Variables.r11Files, "SegoeIcons.ttf"); + SafeFileCopy(segoeicons, SegoeIconsDest); + ImportReg(Path.Combine(Variables.r11Files, "segoeicons.reg")); - var SegoeUIVarDest = Path.Combine(Variables.windir, "Fonts", "SegUIVar.ttf"); - var segoeuivar = Path.Combine(Variables.r11Files, "SegUIVar.ttf"); - File.Copy(segoeuivar, SegoeUIVarDest, true); - Helper.ImportReg(Path.Combine(Variables.r11Files, "segoeuivar.reg")); + var SegoeUIVarDest = Path.Combine(Variables.windir, "Fonts", "SegUIVar.ttf"); + var segoeuivar = Path.Combine(Variables.r11Files, "SegUIVar.ttf"); + SafeFileCopy(segoeuivar, SegoeUIVarDest); + ImportReg(Path.Combine(Variables.r11Files, "segoeuivar.reg")); + } + } + catch (Exception ex) + { + Console.WriteLine(ex.Message + "\n"+ ex.StackTrace); } } diff --git a/Rectify11Installer/Core/Helpers.cs b/Rectify11Installer/Core/Helpers.cs index b599d7cde..14122e005 100644 --- a/Rectify11Installer/Core/Helpers.cs +++ b/Rectify11Installer/Core/Helpers.cs @@ -231,7 +231,7 @@ public static void ImportReg(string path) { try { - Interaction.Shell(Path.Combine(Variables.sys32Folder, "reg.exe") + " import " + path, AppWinStyle.Hide); + Interaction.Shell(Path.Combine(Variables.sys32Folder, "reg.exe") + " import " + path, AppWinStyle.Hide, true); Logger.WriteLine(Path.GetFileName(path) + " succeeded."); } catch (Exception ex)