Skip to content

Commit 4aac961

Browse files
committed
Updated silent switch
1 parent cd3d64f commit 4aac961

File tree

9 files changed

+91
-40
lines changed

9 files changed

+91
-40
lines changed

GoAwayEdge/App.xaml.cs

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public void Application_Startup(object sender, StartupEventArgs e)
5050
IsDebug = true;
5151
if (IsAdministrator() == false)
5252
{
53-
ElevateAsAdmin();
53+
ElevateAsAdmin();
5454
Environment.Exit(0);
5555
return;
5656
}
@@ -70,7 +70,7 @@ public void Application_Startup(object sender, StartupEventArgs e)
7070
{
7171
if (IsAdministrator() == false)
7272
{
73-
ElevateAsAdmin(string.Join(" ", args));
73+
ElevateAsAdmin(string.Join(" ", args));
7474
Environment.Exit(0);
7575
return;
7676
}
@@ -113,25 +113,47 @@ public void Application_Startup(object sender, StartupEventArgs e)
113113
{
114114
foreach (var arg in args)
115115
{
116-
if (arg.StartsWith("-se:"))
116+
if (arg.StartsWith("-e:"))
117117
Configuration.Search = ArgumentParse.ParseSearchEngine(arg);
118-
if (arg.Contains("--url:"))
118+
if (arg.Contains("--search-url:"))
119119
{
120-
Configuration.CustomQueryUrl = ParseCustomSearchEngine(arg);
121-
Configuration.Search = !string.IsNullOrEmpty(Configuration.CustomQueryUrl) ? SearchEngine.Custom : SearchEngine.Google;
120+
Configuration.CustomQueryUrl = ParseCustomUrl(arg, 13);
121+
Configuration.Search = !string.IsNullOrEmpty(Configuration.CustomQueryUrl)
122+
? SearchEngine.Custom
123+
: SearchEngine.Google;
124+
}
125+
126+
if (arg.Contains("-a:"))
127+
Configuration.AiProvider = ArgumentParse.ParseAiProvider(arg);
128+
if (arg.Contains("--ai-url:"))
129+
{
130+
Configuration.CustomAiProviderUrl = ParseCustomUrl(arg, 9);
131+
Configuration.AiProvider = !string.IsNullOrEmpty(Configuration.CustomAiProviderUrl)
132+
? AiProvider.Custom
133+
: AiProvider.Default;
134+
}
135+
136+
if (arg.Contains("-w:"))
137+
Configuration.WeatherProvider = ArgumentParse.ParseWeatherProvider(arg);
138+
if (arg.Contains("--weather-url:"))
139+
{
140+
Configuration.CustomWeatherProviderUrl = ParseCustomUrl(arg, 14);
141+
Configuration.WeatherProvider = !string.IsNullOrEmpty(Configuration.CustomWeatherProviderUrl)
142+
? WeatherProvider.Custom
143+
: WeatherProvider.Default;
122144
}
123145
}
124146

125147
if (IsAdministrator() == false)
126148
{
127-
ElevateAsAdmin(string.Join(" ", args));
149+
ElevateAsAdmin(string.Join(" ", args));
128150
Environment.Exit(0);
129151
return;
130152
}
131153

132154
Configuration.InitialEnvironment();
133-
InstallRoutine.Install(null);
134-
Environment.Exit(0);
155+
var result = InstallRoutine.Install(null);
156+
Environment.Exit(result);
135157
}
136158
if (args.Contains("-u"))
137159
{
@@ -191,7 +213,7 @@ public void Application_Startup(object sender, StartupEventArgs e)
191213
ifeoMessageUi.ShowDialog();
192214

193215
if (ifeoMessageUi.Summary == "Btn1")
194-
ElevateAsAdmin("--update");
216+
ElevateAsAdmin("--update");
195217

196218
Environment.Exit(0);
197219
}
@@ -207,7 +229,7 @@ public void Application_Startup(object sender, StartupEventArgs e)
207229
ifeoMessageUi.ShowDialog();
208230

209231
if (ifeoMessageUi.Summary == "Btn1")
210-
ElevateAsAdmin("--update");
232+
ElevateAsAdmin("--update");
211233

212234
Environment.Exit(0);
213235
}
@@ -240,9 +262,9 @@ private static void ElevateAsAdmin(string? arguments = null)
240262
Process.Start(startInfo);
241263
}
242264

243-
private static string? ParseCustomSearchEngine(string argument)
265+
private static string? ParseCustomUrl(string argument, int count)
244266
{
245-
var argParsed = argument.Remove(0, 6);
267+
var argParsed = argument.Remove(0, count);
246268
var result = Uri.TryCreate(argParsed, UriKind.Absolute, out var uriResult)
247269
&& (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps);
248270
return result ? argParsed : null;

GoAwayEdge/Common/Installation/InstallRoutine.cs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public partial class Shell32
1919
public static partial void SHChangeNotify(uint wEventId, uint uFlags, IntPtr dwItem1, IntPtr dwItem2);
2020
}
2121

22-
public static void Install(object? sender, DoWorkEventArgs? e = null)
22+
public static int Install(object? sender, DoWorkEventArgs? e = null)
2323
{
2424
var worker = sender as BackgroundWorker;
2525

@@ -40,7 +40,7 @@ public static void Install(object? sender, DoWorkEventArgs? e = null)
4040
messageUi.ShowDialog();
4141
});
4242
Environment.Exit(1);
43-
return;
43+
return 1;
4444
}
4545

4646
// Apply registry key
@@ -108,7 +108,7 @@ public static void Install(object? sender, DoWorkEventArgs? e = null)
108108
messageUi.ShowDialog();
109109
});
110110
Environment.Exit(1);
111-
return;
111+
return 1;
112112
}
113113
}
114114
catch (Exception ex)
@@ -121,7 +121,7 @@ public static void Install(object? sender, DoWorkEventArgs? e = null)
121121
messageUi.ShowDialog();
122122
});
123123
Environment.Exit(1);
124-
return;
124+
return 1;
125125
}
126126

127127
// Kill Microsoft Edge processes
@@ -142,7 +142,7 @@ public static void Install(object? sender, DoWorkEventArgs? e = null)
142142
messageUi.ShowDialog();
143143
});
144144
Environment.Exit(1);
145-
return;
145+
return 1;
146146
}
147147
}
148148
else if (!Configuration.NoEdgeInstalled)
@@ -163,7 +163,7 @@ public static void Install(object? sender, DoWorkEventArgs? e = null)
163163
messageUi.ShowDialog();
164164
});
165165
Environment.Exit(1);
166-
return;
166+
return 1;
167167
}
168168
}
169169

@@ -201,7 +201,7 @@ public static void Install(object? sender, DoWorkEventArgs? e = null)
201201
messageUi.ShowDialog();
202202
});
203203
Environment.Exit(1);
204-
return;
204+
return 1;
205205
}
206206

207207
// Register Uninstall data
@@ -216,7 +216,7 @@ public static void Install(object? sender, DoWorkEventArgs? e = null)
216216
messageUi.ShowDialog();
217217
});
218218
Environment.Exit(1);
219-
return;
219+
return 1;
220220
}
221221

222222
// Create Shortcut for Control Panel
@@ -235,6 +235,7 @@ public static void Install(object? sender, DoWorkEventArgs? e = null)
235235
worker?.ReportProgress(100, "");
236236
Logging.Log("Installation finished.");
237237
Console.WriteLine("Installation finished.");
238+
return 0;
238239
}
239240

240241
public static void Uninstall(object? sender, DoWorkEventArgs? e = null)
@@ -417,9 +418,15 @@ internal static bool CopyItself(string pathTo, bool overwrite = false)
417418
}
418419
}
419420

420-
catch (Exception e)
421+
catch (Exception ex)
421422
{
422-
MessageBox.Show(e.ToString());
423+
Logging.Log("Failed to copy itself: " + ex, Logging.LogLevel.ERROR);
424+
Application.Current.Dispatcher.Invoke(() =>
425+
{
426+
var errorMessage = LocalizationManager.LocalizeValue("FailedInstallation", ex.Message);
427+
var messageUi = new MessageUi("GoAwayEdge", errorMessage, "OK");
428+
messageUi.ShowDialog();
429+
});
423430
return false;
424431
}
425432

GoAwayEdge/Common/Runtime/ArgumentParse.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,11 @@ public static EdgeChannel ParseEdgeChannel(string argument)
211211

212212
public static AiProvider ParseAiProvider(string argument)
213213
{
214-
return argument.ToLower() switch
214+
var arg = argument;
215+
if (argument.StartsWith("-a:"))
216+
arg = argument.Remove(0, 3);
217+
218+
return arg.ToLower() switch
215219
{
216220
"default" => AiProvider.Default,
217221
"copilot" => AiProvider.Copilot,
@@ -227,8 +231,8 @@ public static AiProvider ParseAiProvider(string argument)
227231
public static SearchEngine ParseSearchEngine(string argument)
228232
{
229233
var arg = argument;
230-
if (argument.StartsWith("-se:"))
231-
arg = argument.Remove(0, 4);
234+
if (argument.StartsWith("-e:"))
235+
arg = argument.Remove(0, 3);
232236

233237
return arg.ToLower() switch
234238
{
@@ -248,7 +252,11 @@ public static SearchEngine ParseSearchEngine(string argument)
248252

249253
public static WeatherProvider ParseWeatherProvider(string argument)
250254
{
251-
return argument.ToLower() switch
255+
var arg = argument;
256+
if (argument.StartsWith("-w:"))
257+
arg = argument.Remove(0, 3);
258+
259+
return arg.ToLower() switch
252260
{
253261
"default" => WeatherProvider.Default,
254262
"weathercom" => WeatherProvider.WeatherCom,

GoAwayEdge/Localization/ResourceDictionary.de-DE.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
<!-- Setup finished -->
4646
<system:String x:Key="SetupFinishedTitle">Installation abgeschlossen!</system:String>
4747
<system:String x:Key="SetupFinishedDescription">Öffnen Sie das Installationsprogramm, wenn Sie GoAwayEdge erneut anpassen möchten.</system:String>
48+
<system:String x:Key="SetupFinishedDescriptionWithControlPanel">Öffnen Sie das Installationsprogramm oder das Kontrollpanel, wenn Sie GoAwayEdge erneut anpassen möchten.</system:String>
4849
<system:String x:Key="UninstallFinishedTitle">Deinstallation abgeschlossen!</system:String>
4950
<system:String x:Key="UninstallFinishedDescription">GoAwayEdge wurde erfolgreich vom System entfernt.</system:String>
5051
<system:String x:Key="DonateButton">Über PayPal spenden</system:String>

GoAwayEdge/Localization/ResourceDictionary.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
<!-- Setup finished -->
5656
<system:String x:Key="SetupFinishedTitle">Installation completed!</system:String>
5757
<system:String x:Key="SetupFinishedDescription">Simply open this Installer, if you want to customize GoAwayEdge again.</system:String>
58+
<system:String x:Key="SetupFinishedDescriptionWithControlPanel">Simply open this installer or the Control Panel if you want to customize GoAwayEdge again.</system:String>
5859
<system:String x:Key="UninstallFinishedTitle">Uninstallation completed!</system:String>
5960
<system:String x:Key="UninstallFinishedDescription">GoAwayEdge has been successfully removed from the system.</system:String>
6061
<system:String x:Key="DonateButton">Donate via PayPal</system:String>

GoAwayEdge/UserInterface/Setup/Installer.xaml.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ internal void NextBtn_OnClick(object sender, RoutedEventArgs e)
6565
NextBtn.IsEnabled = false;
6666
BackBtn.IsEnabled = true;
6767
FrameWindow.Content = _redirectOrRemovePage;
68-
SettingPage = new Settings();
6968
break;
7069
}
7170
}
@@ -81,7 +80,7 @@ private void BackBtn_OnClick(object sender, RoutedEventArgs e)
8180
FrameWindow.Content = LicensePage;
8281
break;
8382
case Settings:
84-
NextBtn.IsEnabled = true;
83+
NextBtn.IsEnabled = false;
8584
BackBtn.IsEnabled = true;
8685
FrameWindow.Content = _redirectOrRemovePage;
8786
break;

GoAwayEdge/UserInterface/Setup/Pages/Installation.xaml.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public Installation()
2323
}
2424
else
2525
{
26-
applyBackgroundWorker.DoWork += InstallRoutine.Install;
26+
applyBackgroundWorker.DoWork += InstallRoutine_Install;
2727
}
2828
applyBackgroundWorker.ProgressChanged += ApplyBackgroundWorker_ProgressChanged;
2929
applyBackgroundWorker.RunWorkerAsync();
@@ -36,5 +36,10 @@ private static void ApplyBackgroundWorker_ProgressChanged(object? sender, Progre
3636
Installer.ContentWindow?.FrameWindow.NavigationService.Navigate(new InstallationSuccess());
3737
}
3838
}
39+
40+
private static void InstallRoutine_Install(object? sender, DoWorkEventArgs e)
41+
{
42+
e.Result = InstallRoutine.Install(sender, e);
43+
}
3944
}
4045
}

GoAwayEdge/UserInterface/Setup/Pages/InstallationSuccess.xaml.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ public InstallationSuccess()
1919
Installer.ContentWindow!.NextBtn.Content = !string.IsNullOrEmpty(exitResource)
2020
? exitResource : "Exit";
2121

22+
var setupDescriptionResource = Configuration.InstallControlPanel ?
23+
(string)Application.Current.MainWindow!.FindResource("SetupFinishedDescriptionWithControlPanel") : (string)Application.Current.MainWindow!.FindResource("SetupFinishedDescription");
24+
SetupDescription.Text = setupDescriptionResource;
25+
2226
if (Configuration.Uninstall)
2327
{
2428
Dispatcher.Invoke(() =>

README.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<a href="https://translate.valnoxy.dev/engage/goawayedge/">Help me translate</a>
3939
<br />
4040
<br />
41-
🎉 Version 1.3.4 is out. Check out the release notes
41+
🎉 Version 2.0.0 is out. Check out the release notes
4242
<a href="https://github.com/valnoxy/GoAwayEdge/releases">here</a>.
4343
<br />
4444
<br />
@@ -72,17 +72,21 @@ Feel free to explore the code, contribute, or simply enjoy a browser experience
7272
## 🤫 2. Silent Installation
7373
You can install GoAwayEdge silently by parsing the following arguments:
7474

75-
| Switch | Description |
76-
| ----------------- | ------------------------------------------------------------------------- |
77-
| `-s` | Silent installation |
78-
| `-se:<Engine>` | Specify the Search Engine: `Google` (default), `Bing`, `DuckDuckGo`, `Yahoo`, `Yandex`, `Ecisua`, `Ask`, `Quant`, `Perplexity` |
79-
| `--url:<Url>` | Custom search query url (ex: `https://google.com/search?q=`) |
75+
| Switch | Description |
76+
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------ |
77+
| `-s` | Silent installation |
78+
| `-e:<Engine>` | Specify the Search Engine: `Google` (default), `Bing`, `DuckDuckGo`, `Yahoo`, `Yandex`, `Ecisua`, `Ask`, `Quant`, `Perplexity` |
79+
| `-a:<AI Service>` | Specify the AI Service: `Default`, `Copilot`, `ChatGPT`, `Gemini`, `GitHub_Copilot`, `Grok`, |
80+
| `-w:<Weather Service>` | Specify the Weather Service: `Default`, `WeatherCom`, `AccuWeather` |
81+
| `--search-url:<Url>` | Custom search query url (ex: `https://google.com/search?q=`) |
82+
| `--ai-url:<Url>` | Custom AI website (ex: `https://chatgpt.com`) |
83+
| `--weather-url:<Url>` | Custom weather query url (ex: `https://my-weather.com/{country-code}/{latitude},{longitude}`) |
8084

8185
<b>Example</b>:
8286

8387
```bat
84-
GoAwayEdge.exe -s -se:DuckDuckGo
85-
```
88+
GoAwayEdge.exe -s -e:DuckDuckGo
89+
```
8690

8791
# 🗑️ Remove GoAwayEdge
8892
You can uninstall GoAwayEdge just like any other application. Alternatively, you can also take this way:
@@ -91,7 +95,7 @@ You can uninstall GoAwayEdge just like any other application. Alternatively, you
9195
3. Click on ```Uninstall```.
9296
4. Done!
9397

94-
You can also uninstall GoAwayEdge by parsing the following argument:
98+
You can also silently uninstall GoAwayEdge by parsing the following argument:
9599
```bat
96100
GoAwayEdge.exe -u
97101
```
@@ -110,7 +114,7 @@ This project uses the following libraries:
110114
GoAwayEdge is licensed under [MIT](https://github.com/valnoxy/GoAwayEdge/blob/main/LICENSE). So you are allowed to use freely and modify the application. I will not be responsible for any outcome. Proceed with any action at your own risk.
111115

112116
<hr>
113-
<h6 align="center">© 2018 - 2024 valnoxy. All Rights Reserved.
117+
<h6 align="center">© 2018 - 2025 valnoxy. All Rights Reserved.
114118
<br>
115119
By Jonas Günner &lt;jonas@exploitox.de&gt;</h6>
116120
<p align="center">

0 commit comments

Comments
 (0)