-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathProgram.cs
More file actions
180 lines (154 loc) · 6.04 KB
/
Copy pathProgram.cs
File metadata and controls
180 lines (154 loc) · 6.04 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
using Microsoft.Win32;
using System;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Windows.Forms;
namespace Coffeed
{
static class Program
{
public static double Version = 0.4;
static WebClient client;
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
AutoPatcher.Patch();
Logging.InitLog();
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
client = new WebClient()
{
Encoding = System.Text.Encoding.UTF8,
};
client.Headers.Add("User-Agent: Other");
if (!string.IsNullOrEmpty(PuttyDetector()) && !string.IsNullOrEmpty(FileZillaDetector()))
{
if (File.Exists(Path.Combine(Application.StartupPath, "PublicKey.xml")))
{
Application.Run(new FormMain());
}
else
{
Application.Run(new FormInit());
}
}
else
{
Application.Run(new frmSoftwareDetector());
}
}
public static string PuttyDetector()
{
var result = string.Empty;
try
{
RegistryView rv = RegistryView.Registry32;
if (Environment.Is64BitOperatingSystem) rv = RegistryView.Registry64;
var keyView = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, rv);
var key32 = keyView.OpenSubKey(@"SOFTWARE\WOW6432Node\SimonTatham\PuTTY\CHMPath", false);
var key64 = keyView.OpenSubKey(@"SOFTWARE\SimonTatham\PuTTY64\CHMPath", false);
if (key32 != null)
{
var puttyPath = Path.Combine(Path.GetDirectoryName(key32.GetValue("").ToString()), "putty.exe");
if (File.Exists(puttyPath))
{
result = puttyPath;
}
else
{
result = string.Empty;
}
}
if (key64 != null)
{
var puttyPath = Path.Combine(Path.GetDirectoryName(key64.GetValue("").ToString()), "putty.exe");
if (File.Exists(puttyPath))
{
result = puttyPath;
}
else
{
result = string.Empty;
}
}
}
catch (Exception err)
{
Logging.M(err.Message, "Oops, there's an error that needs special attetion.");
Logging.LogError(err);
return string.Empty;
}
return result;
}
public static string FileZillaDetector()
{
string result = string.Empty;
try
{
RegistryView rv = RegistryView.Registry32;
if (Environment.Is64BitOperatingSystem) rv = RegistryView.Registry64;
var key = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, rv);
var fzkey = key.OpenSubKey(@"SOFTWARE\WOW6432Node\FileZilla Client", false);
if (fzkey != null)
{
string path = (string)fzkey.GetValue("", string.Empty);
if (System.IO.File.Exists(Path.Combine(path, "filezilla.exe")))
{
result = Path.Combine(path, "filezilla.exe");
}
else
{
result = string.Empty;
}
}
}
catch (Exception err)
{
Logging.M(err.Message, "Oops, there's an error that needs special attetion.");
Logging.LogError(err);
return string.Empty;
}
return result;
}
public static void InstallFileZilla()
{
//try
//{
// string link = "http://185.138.43.38/plesk-site-preview/xostme.gr/https/185.138.43.38/FileZilla_3.56.2_win32-setup.exe";
// if (Environment.Is64BitOperatingSystem) link = "http://185.138.43.38/plesk-site-preview/xostme.gr/https/185.138.43.38/FileZilla_3.56.2_win64-setup.exe";
// client.DownloadFile(link, Path.Combine(Path.GetTempPath(), "FileZillaSetup.exe"));
// Process p = new Process();
// p.StartInfo.WorkingDirectory = Path.GetTempPath();
// p.StartInfo.FileName = Path.Combine(Path.GetTempPath(), "FileZillaSetup.exe");
// p.Start();
// p.WaitForExit();
//}
//catch (Exception err)
//{
// Logging.M(err.Message, "Oops, there's an error that needs special attetion.");
// Logging.LogError(err);
//}
}
public static void InstallPutty()
{
//try
//{
// string link = "https://the.earth.li/~sgtatham/putty/latest/w32/putty-0.76-installer.msi";
// if (Environment.Is64BitOperatingSystem) link = "https://the.earth.li/~sgtatham/putty/latest/w64/putty-64bit-0.76-installer.msi";
// client.DownloadFile(link, Path.Combine(Path.GetTempPath(), "PuttySetup.msi"));
// Process p = new Process();
// p.StartInfo.WorkingDirectory = Path.GetTempPath();
// p.StartInfo.FileName = Path.Combine(Path.GetTempPath(), "PuttySetup.msi");
// p.Start();
// p.WaitForExit();
//}
//catch (Exception err)
//{
// Logging.M(err.Message, "Oops, there's an error that needs special attetion.");
// Logging.LogError(err);
//}
}
}
}