-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
72 lines (65 loc) · 2.35 KB
/
Program.cs
File metadata and controls
72 lines (65 loc) · 2.35 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace BepInExInstall
{
static class Program
{
[STAThread]
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
if (args.Length > 0)
{
string arg = args[0].ToLower();
string path = args.Length > 1 ? args[1] : string.Empty;
if (arg == "--install" && !string.IsNullOrEmpty(path))
{
RunCliInstall(path).Wait();
return;
}
else if (arg == "--uninstall" && !string.IsNullOrEmpty(path))
{
BepInExManager.UninstallBepInEx(path);
Console.WriteLine("BepInEx successfully uninstalled.");
return;
}
else
{
Console.WriteLine("Usage:");
Console.WriteLine(" --install <path_to_exe>");
Console.WriteLine(" --uninstall <path_to_exe>");
return;
}
}
Application.Run(new Main());
}
static async Task RunCliInstall(string exePath)
{
Console.WriteLine("Installing BepInEx...");
GameInfo.gameProcess = new System.Diagnostics.Process();
GameInfo.unityType = UnityType.Mono; // default assumption
GameInfo.arcteture = Arcteture.x64; // default assumption
GameInfo.selected_version = VersionsBepInEx.v5_4_15; // DEFAULT version
try
{
bool result = await BepInExManager.InstallBepInEx(
exePath,
progress => Console.Write($"\rProgress: {progress}%"),
status => Console.WriteLine($"\n{status}")
);
if (result)
Console.WriteLine("\nInstallation completed successfully!");
else
Console.WriteLine("\nInstallation failed or was canceled.");
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
}
}
}