-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
94 lines (91 loc) · 3.73 KB
/
Program.cs
File metadata and controls
94 lines (91 loc) · 3.73 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
using System.Diagnostics;
namespace DownloadManagerInstaller
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[]? args)
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
try
{
if (args != null)
{
if (args.Length > 0)
{
if (args[0] == "--install")
{
// Install
Application.Run(new Form1(new string[] { "install" }));
}
else if (args[0] == "--update")
{
// Update
Application.Run(new Form1(new string[] { "update" }));
}
else if (args[0] == "--uninstall")
{
// Uninstall
try
{
if (args[1] == null || args[1] == "")
{
Application.Run(new Form1(new string[] { "uninstall" }));
}
else
{
Application.Run(new Form1(new string[]{
"uninstall",
args[1]
}));
}
}
catch
{
Application.Run(new Form1(new string[] { "uninstall" }));
}
}
else
{
Application.Run(new Form1(null));
}
}
else
{
Application.Run(new Form1(null));
}
}
else
{
Application.Run(new Form1(null));
}
}
catch (Exception ex)
{
Application.ExitThread();
DialogResult result = MessageBox.Show("A fatal error occurred and Download Manager installer cannot continue.\nClick 'Cancel' to exit the application now.\nClick 'Retry' to open a new instance of the installer.\nPlease file a bug report with the following information.\n" + ex.Message + Environment.NewLine + ex.StackTrace, "Fatal Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
if (result == DialogResult.Retry)
{
try
{
ProcessStartInfo info = new ProcessStartInfo();
info.FileName = Application.ExecutablePath;
info.Arguments = args.ToString();
info.UseShellExecute = true;
Process.Start(info);
}
catch
{
MessageBox.Show("Failed to start a new instance of the installer.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
Application.Exit();
}
}
}
}
}