forked from KodeByWrath/NoMoreEdge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNoMoreEdgeSetup.cs
102 lines (92 loc) · 3.52 KB
/
NoMoreEdgeSetup.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.IO;
using System.Net;
using System.Diagnostics;
/*
* Copyright © 2017–2021 Harshal Kudale
* SPDX-License-Identifier: MIT
* License-Filename: LICENSE
*/
namespace NoMoreEdgeSetup
{
static class NoMoreEdgeSetupForm
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
public static void installApp(string path,string edgepath,string newedge,string destFile,string engine )
{
try
{
using (var client = new WebClient())
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
client.DownloadFile("https://github.com/HarshalKudale/NoMoreEdge/releases/download/1.0.1.0/NoMoreEdge.exe", destFile);
}
File.Copy(edgepath, newedge, true);
}
catch (IOException iox)
{
Console.WriteLine(iox.Message);
Console.WriteLine(iox.Message);
}
Microsoft.Win32.RegistryKey rkey;
string apppath = "C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\NoMoreEdge.exe " + engine;
rkey = Microsoft.Win32.Registry.LocalMachine.CreateSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Image File Execution Options\\msedge.exe");
rkey.SetValue("Debugger", apppath);
rkey.Close();
MessageBox.Show("Installed NoMoreEdge - https://github.com/HarshalKudale/NoMoreEdge");
}
public static void updateApp(string path,string engine)
{
if (File.Exists(path))
{
try
{
Microsoft.Win32.RegistryKey rkey;
string apppath = "C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\NoMoreEdge.exe " + engine;
rkey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Image File Execution Options\\msedge.exe",true);
rkey.SetValue("Debugger", apppath);
rkey.Close();
MessageBox.Show("Search Engine updated");
}
catch(Exception ex)
{
throw new ArgumentException("Could not find registry key: " + ex);
}
}
else
{
MessageBox.Show("NoMoreEdge is not installed");
}
}
public static void exitSetup()
{
Application.Exit();
}
public static void uninstallApp(string path, string newedge)
{
if (File.Exists(path))
{
File.Delete(path);
File.Delete(newedge);
Microsoft.Win32.Registry.LocalMachine.DeleteSubKeyTree("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Image File Execution Options\\msedge.exe");
MessageBox.Show("Uninstalled NoMoreEdge");
}
else
{
MessageBox.Show("NoMoreEdge is not installed");
}
}
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}