Skip to content

Commit 5c2aeb8

Browse files
committed
Try to delete EventLog key
- Don`t know why it`s there on some systems?
1 parent 925c429 commit 5c2aeb8

File tree

4 files changed

+48
-6
lines changed

4 files changed

+48
-6
lines changed

SimpleDnsCrypt/Helper/DnsCryptProxyManager.cs

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
using System.ComponentModel;
44
using System.Diagnostics;
55
using System.IO;
6+
using System.Security.AccessControl;
67
using System.ServiceProcess;
78
using System.Text;
89
using System.Threading;
910
using Caliburn.Micro;
11+
using Microsoft.Win32;
1012
using Nett;
1113
using Newtonsoft.Json;
1214
using SimpleDnsCrypt.Config;
@@ -267,7 +269,27 @@ public static List<AvailableResolver> GetAllResolversWithFilters()
267269
public static bool Install()
268270
{
269271
var result = ExecuteWithArguments("-service install");
270-
return result.Success;
272+
if (result.Success)
273+
{
274+
return true;
275+
}
276+
277+
try
278+
{
279+
if (string.IsNullOrEmpty(result.StandardError)) return false;
280+
if (result.StandardError.Contains("SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\dnscrypt-proxy"))
281+
{
282+
Registry.LocalMachine.DeleteSubKey(@"SYSTEM\CurrentControlSet\Services\EventLog\Application\dnscrypt-proxy",
283+
false);
284+
return Install();
285+
}
286+
}
287+
catch (Exception exception)
288+
{
289+
Log.Error(exception);
290+
}
291+
292+
return false;
271293
}
272294

273295
/// <summary>
@@ -277,6 +299,21 @@ public static bool Install()
277299
public static bool Uninstall()
278300
{
279301
var result = ExecuteWithArguments("-service uninstall");
302+
try
303+
{
304+
var eventLogKey = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Services\EventLog\Application\dnscrypt-proxy",
305+
RegistryRights.ReadKey);
306+
var eventLogKeyValue = eventLogKey?.GetValue("CustomSource");
307+
if (eventLogKeyValue != null)
308+
{
309+
Registry.LocalMachine.DeleteSubKey(@"SYSTEM\CurrentControlSet\Services\EventLog\Application\dnscrypt-proxy", false);
310+
}
311+
}
312+
catch (Exception exception)
313+
{
314+
Log.Error(exception);
315+
}
316+
280317
return result.Success;
281318
}
282319

SimpleDnsCrypt/ViewModels/MainViewModel.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,10 @@ public void OpenLogDirectory()
623623
try
624624
{
625625
var logDirectory = Path.Combine(Directory.GetCurrentDirectory(), "logs");
626-
Process.Start(logDirectory);
626+
if (Directory.Exists(logDirectory))
627+
{
628+
Process.Start(logDirectory);
629+
}
627630
}
628631
catch (Exception exception)
629632
{
@@ -649,8 +652,8 @@ public void SaveLocalServers()
649652
}
650653
else
651654
{
652-
//TODO: translate
653-
_windowManager.ShowMetroMessageBox("At least one server must be selected. Otherwise, dnscrypt-proxy uses all servers corresponding to the selected filters.", "No server selected",
655+
_windowManager.ShowMetroMessageBox(LocalizationEx.GetUiString("message_content_no_server_selected", Thread.CurrentThread.CurrentCulture),
656+
LocalizationEx.GetUiString("message_title_no_server_selected", Thread.CurrentThread.CurrentCulture),
654657
MessageBoxButton.OK, BoxType.Warning);
655658
}
656659
}

Uninstall/Program.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.IO;
55
using System.Net.NetworkInformation;
66
using System.Threading;
7+
using Microsoft.Win32;
78

89
namespace Uninstall
910
{
@@ -40,6 +41,7 @@ internal static void UninstallService()
4041
{
4142
Console.WriteLine("removing dnscrypt service");
4243
ExecuteWithArguments("-service uninstall");
44+
Registry.LocalMachine.DeleteSubKey(@"SYSTEM\CurrentControlSet\Services\EventLog\Application\dnscrypt-proxy", false);
4345
}
4446

4547
/// <summary>

Uninstall/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
[assembly: AssemblyCulture("")]
1212
[assembly: ComVisible(false)]
1313
[assembly: Guid("1a9ca4fe-bdd5-4d7c-a86a-7ed503974718")]
14-
[assembly: AssemblyVersion("0.2.1")]
15-
[assembly: AssemblyFileVersion("0.2.1")]
14+
[assembly: AssemblyVersion("0.2.2")]
15+
[assembly: AssemblyFileVersion("0.2.2")]

0 commit comments

Comments
 (0)