-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
104 lines (89 loc) · 3.52 KB
/
Program.cs
File metadata and controls
104 lines (89 loc) · 3.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
using System.Diagnostics;
using System.Text.Json;
using System.Text.Json.Nodes;
namespace NoVgLoL
{
class Program
{
private static bool RemoveVanguard()
{
if (!OperatingSystem.IsWindows())
{
return true;
}
string vgkpath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "Riot Vanguard", "installer.exe");
if (!File.Exists(vgkpath))
{
return true;
}
try
{
using var process = Process.Start(vgkpath, "--quiet");
if (process != null)
{
Console.WriteLine(" [INFO] Attempting to uninstall Vanguard...");
process.WaitForExit();
Thread.Sleep(5000);
for (int i = 0; i < 30; i++)
{
if (!File.Exists(vgkpath))
{
Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine(" [OKAY] Vanguard uninstallation completed, starting League now...");
Console.ResetColor();
return true;
}
Thread.Sleep(1000);
}
Console.ForegroundColor = ConsoleColor.DarkYellow;
Console.WriteLine(" [WARN] Vanguard uninstallation failed, try running this app as administrator.");
Console.ResetColor();
return false;
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(" [ERROR] Failed to start Vanguard uninstallation process.");
Console.ResetColor();
return false;
}
}
catch (Exception ex)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine($" [ERROR] Vanguard uninstallation aborted: {ex}");
Console.ResetColor();
return false;
}
}
public static async Task Main(string[] args)
{
var leagueProxy = new LeagueProxy();
leagueProxy.Start();
if (!RemoveVanguard())
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(" [ERROR] Vanguard uninstall failed, try running app as administator.");
Console.ResetColor();
leagueProxy.Stop();
return;
}
Console.WriteLine(" [INFO] Starting RCS process...");
var process = leagueProxy.LaunchRCS(args);
if (process is null)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(" [ERROR] Failed to launch RCS process. Try running this app as administrator.");
Console.ResetColor();
leagueProxy.Stop();
return;
}
Console.ForegroundColor = ConsoleColor.Cyan;
Console.WriteLine(" [OKAY] Started RCS process.");
Console.ResetColor();
await process.WaitForExitAsync();
Console.WriteLine(" [INFO] RCS process exited");
leagueProxy.Stop();
}
}
}