From 4e877ded68f1743b27aa8f18f29d008a5ebf44a2 Mon Sep 17 00:00:00 2001 From: Jared Date: Thu, 17 Dec 2020 18:12:44 -0800 Subject: [PATCH] Remove Uninstall reg key when agent uninstalls itself. --- Agent/Services/Uninstaller.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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)