diff --git a/Installer Projects/CustomActions/CustomActions.cs b/Installer Projects/CustomActions/CustomActions.cs
index 2ecdf6a36..8d8c5f719 100644
--- a/Installer Projects/CustomActions/CustomActions.cs
+++ b/Installer Projects/CustomActions/CustomActions.cs
@@ -27,5 +27,34 @@ namespace CustomActions
session.Log("End IsKBInstalled");
return ActionResult.Success;
}
+
+ [CustomAction]
+ public static ActionResult UninstallLegacyVersion(Session session)
+ {
+ session.Log("Begin UninstallLegacyVersion");
+ UninstallNSISVersions uninstaller = new UninstallNSISVersions();
+ string uninstallString = uninstaller.GetLegacyUninstallString();
+ uninstaller.UninstallLegacyVersion();
+ session.Log("End UninstallLegacyVersion");
+ return ActionResult.Success;
+ }
+
+ [CustomAction]
+ public static ActionResult IsLegacyVersionInstalled(Session session)
+ {
+ session.Log("Begin IsLegacyVersionInstalled");
+ UninstallNSISVersions uninstaller = new UninstallNSISVersions();
+ if (uninstaller.IsLegacymRemoteNGInstalled())
+ {
+ session["LEGACYVERSIONINSTALLED"] = "1";
+ }
+ else
+ {
+ session["LEGACYVERSIONINSTALLED"] = "0";
+ }
+
+ session.Log("End IsLegacyVersionInstalled");
+ return ActionResult.Success;
+ }
}
}
\ No newline at end of file
diff --git a/Installer Projects/CustomActions/CustomActions.csproj b/Installer Projects/CustomActions/CustomActions.csproj
index c24e2fced..ce2277102 100644
--- a/Installer Projects/CustomActions/CustomActions.csproj
+++ b/Installer Projects/CustomActions/CustomActions.csproj
@@ -33,7 +33,8 @@
4
-
+
+
@@ -46,6 +47,7 @@
+
diff --git a/Installer Projects/CustomActions/UninstallNSISVersions.cs b/Installer Projects/CustomActions/UninstallNSISVersions.cs
new file mode 100644
index 000000000..17866ade2
--- /dev/null
+++ b/Installer Projects/CustomActions/UninstallNSISVersions.cs
@@ -0,0 +1,75 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Microsoft.Win32;
+using System.Diagnostics;
+using System.IO;
+
+namespace CustomActions
+{
+ public class UninstallNSISVersions
+ {
+ private const string REGISTRY_PATH = "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\mRemoteNG";
+ private const string REGISTRY_PATH_Wow6432 = "Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\mRemoteNG";
+ private RegistryKey _activeRegistryPath;
+
+
+ public UninstallNSISVersions()
+ {
+ GetLegacymRemoteNGRegistryKeyPath();
+ }
+
+ public void UninstallLegacyVersion()
+ {
+ if (!IsLegacymRemoteNGInstalled())
+ return;
+ string uninstallString = GetLegacyUninstallString();
+ ProcessStartInfo processStartInfo = new ProcessStartInfo(uninstallString);
+ processStartInfo.UseShellExecute = true;
+ processStartInfo.Arguments = string.Format("_?={0}", uninstallString.Replace("Uninstall.exe", "").Replace(@"""", ""));
+ Process uninstallProcess = Process.Start(processStartInfo);
+ while (uninstallProcess.HasExited == false)
+ {
+ Debug.WriteLine("Waiting for uninstaller to exit");
+ }
+ }
+
+ public bool IsLegacymRemoteNGInstalled()
+ {
+ return (_activeRegistryPath != null);
+ }
+
+ public string GetLegacyUninstallString()
+ {
+ if (IsLegacymRemoteNGInstalled())
+ return _activeRegistryPath.GetValue("UninstallString").ToString();
+ return "";
+ }
+
+ private void GetLegacymRemoteNGRegistryKeyPath()
+ {
+ GetUninstallKeyPath();
+ GetUninstallKeyPath6432();
+ }
+
+ private void GetUninstallKeyPath()
+ {
+ try
+ {
+ _activeRegistryPath = Registry.LocalMachine.OpenSubKey(REGISTRY_PATH);
+ }
+ catch (Exception ex)
+ { }
+ }
+
+ private void GetUninstallKeyPath6432()
+ {
+ try
+ {
+ _activeRegistryPath = Registry.LocalMachine.OpenSubKey(REGISTRY_PATH_Wow6432);
+ }
+ catch (Exception ex)
+ { }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Installer Projects/Installer/CustomActions/UninstallLegacyVersions.wxs b/Installer Projects/Installer/CustomActions/UninstallLegacyVersions.wxs
new file mode 100644
index 000000000..65dc0d172
--- /dev/null
+++ b/Installer Projects/Installer/CustomActions/UninstallLegacyVersions.wxs
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Installer Projects/Installer/Installer.wixproj b/Installer Projects/Installer/Installer.wixproj
index 8f3a1f9fe..e5c926bdc 100644
--- a/Installer Projects/Installer/Installer.wixproj
+++ b/Installer Projects/Installer/Installer.wixproj
@@ -27,6 +27,7 @@
+
diff --git a/Installer Projects/Installer/mRemoteNGV1.wxs b/Installer Projects/Installer/mRemoteNGV1.wxs
index 991c1c1e2..7889f333b 100644
--- a/Installer Projects/Installer/mRemoteNGV1.wxs
+++ b/Installer Projects/Installer/mRemoteNGV1.wxs
@@ -17,13 +17,17 @@
+
- NOT Installed AND (VersionNT = 601 OR VersionNT64 = 601)
+ (NOT Installed) AND (VersionNT = 601 OR VersionNT64 = 601)
+
+
+ (NOT Installed) AND (LEGACYVERSIONINSTALLED = 1)