-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
85 lines (72 loc) · 3.01 KB
/
Copy pathProgram.cs
File metadata and controls
85 lines (72 loc) · 3.01 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
using IWshRuntimeLibrary;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
namespace Codex_Ipsa.Installer
{
internal class Program
{
public static String thePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), ".codexipsa");
static void Main(string[] args)
{
Console.Title = "Codex-Ipsa Installer v1.0";
WebClient client = new WebClient();
Directory.CreateDirectory(thePath);
if (System.IO.File.Exists(thePath + "\\MCLauncher.exe"))
{
Console.WriteLine("Seems like you already have the launcher installed.");
Console.WriteLine("Do you wish to repair it? [y/n]");
Console.Write("> ");
ConsoleKeyInfo yn = Console.ReadKey();
if (yn.KeyChar == 'y')
{
System.IO.File.Delete($"{thePath}\\MCLauncher.exe");
if (System.IO.File.Exists($"{thePath}\\DiscordRPC.dll"))
System.IO.File.Delete($"{thePath}\\DiscordRPC.dll");
if (System.IO.File.Exists($"{thePath}\\Newtonsoft.Json.dll"))
System.IO.File.Delete($"{thePath}\\Newtonsoft.Json.dll");
}
else
{
return;
}
}
//get versions info
String verJson = client.DownloadString("http://files.codex-ipsa.cz/update/manifest.json");
List<UpdateJson> uj = JsonConvert.DeserializeObject<List<UpdateJson>>(verJson);
foreach (UpdateJson v in uj)
{
//download the stable release
if (v.id == "stable")
{
//download launcher zip
Console.WriteLine("Downloading the launcher...");
client.DownloadFile(v.url, $"{thePath}\\launcher.zip");
//extract launcher zip
ZipFile.ExtractToDirectory($"{thePath}\\launcher.zip", thePath);
System.IO.File.Delete($"{thePath}\\launcher.zip");
//create link on desktop
CreateShortcut();
Console.WriteLine("Installed!");
break;
}
}
}
static void CreateShortcut()
{
object shDesktop = (object)"Desktop";
WshShell shell = new WshShell();
string shortcutAddress = (string)shell.SpecialFolders.Item(ref shDesktop) + @"\Codex-Ipsa Launcher.lnk";
IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(shortcutAddress);
shortcut.TargetPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\.codexipsa\MCLauncher.exe";
shortcut.Save();
}
}
}