Remove Uninstall reg key when agent uninstalls itself.

This commit is contained in:
Jared 2020-12-17 18:12:44 -08:00 committed by Jared Goodwin
parent a0ef956e57
commit 4e877ded68

View File

@ -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)