Skip to content

Commit

Permalink
fix installfonts
Browse files Browse the repository at this point in the history
  • Loading branch information
rounk-ctrl committed Sep 27, 2023
1 parent 3d18d74 commit 814e8a1
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 23 deletions.
18 changes: 16 additions & 2 deletions Rectify11.Phase2/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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)
{
Expand Down
48 changes: 28 additions & 20 deletions Rectify11.Phase2/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Rectify11Installer/Core/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 814e8a1

Please sign in to comment.