-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.cs
More file actions
48 lines (44 loc) · 1.33 KB
/
setup.cs
File metadata and controls
48 lines (44 loc) · 1.33 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
using System;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Windows.Forms;
class QuickPathsSetup
{
[STAThread]
static void Main()
{
string installDir = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
"QuickPaths");
string exeUrl = "https://github.com/Sebastilan/QuickPaths/releases/latest/download/QuickPaths.exe";
string exePath = Path.Combine(installDir, "QuickPaths.exe");
try
{
// Create install dir
Directory.CreateDirectory(installDir);
// Download exe
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
using (var wc = new WebClient())
{
wc.DownloadFile(exeUrl, exePath);
}
// Run install
var psi = new ProcessStartInfo
{
FileName = exePath,
Arguments = "--install",
UseShellExecute = true
};
Process.Start(psi);
}
catch (Exception ex)
{
MessageBox.Show(
"Installation failed:\n" + ex.Message,
"QuickPaths Setup",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}