diff --git a/Agent/Services/Uninstaller.cs b/Agent/Services/Uninstaller.cs index 342878dc..d968dea1 100644 --- a/Agent/Services/Uninstaller.cs +++ b/Agent/Services/Uninstaller.cs @@ -1,4 +1,5 @@ -using Remotely.Shared.Utilities; +using Microsoft.Win32; +using Remotely.Shared.Utilities; using System; using System.Diagnostics; using System.IO; @@ -12,7 +13,14 @@ namespace Remotely.Agent.Services if (EnvironmentHelper.IsWindows) { Process.Start("cmd.exe", "/c sc delete Remotely_Service"); - var currentDir = AppDomain.CurrentDomain.BaseDirectory; + + var view = Environment.Is64BitOperatingSystem ? + "/reg:64" : + "/reg:32"; + + Process.Start("cmd.exe", @$"/c REG DELETE HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Remotely /f {view}"); + + var currentDir = Path.GetDirectoryName(typeof(Uninstaller).Assembly.Location); Process.Start("cmd.exe", $"/c timeout 5 & rd /s /q \"{currentDir}\""); } else if (EnvironmentHelper.IsLinux)