mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 22:11:48 +08:00
Installer now accepts either the RDP8 or RDP8.1 KB
This commit is contained in:
@@ -7,16 +7,20 @@ namespace CustomActions
|
||||
[CustomAction]
|
||||
public static ActionResult IsMinimumRdpVersionInstalled(Session session)
|
||||
{
|
||||
var rdpVersionChecker = new InstalledKbChecker("MINIMUM_RDP_KB", "MINIMUM_RDP_VERSION_INSTALLED", session);
|
||||
rdpVersionChecker.Execute();
|
||||
var acceptedRdpKbVariables = new[] { session["RDP80_KB"], session["RDP81_KB"] };
|
||||
var returnVariable = "MINIMUM_RDP_VERSION_INSTALLED";
|
||||
var kbInstalledChecker = new KbInstalledChecker(session);
|
||||
kbInstalledChecker.Execute(acceptedRdpKbVariables, returnVariable);
|
||||
return ActionResult.Success;
|
||||
}
|
||||
|
||||
[CustomAction]
|
||||
public static ActionResult IsRdpDtlsUpdateInstalled(Session session)
|
||||
{
|
||||
var rdpVersionChecker = new InstalledKbChecker("RDP_DTLS_KB", "RDP_DTLS_UPDATE_INSTALLED", session);
|
||||
rdpVersionChecker.Execute();
|
||||
var kb = session["RDP_DTLS_KB"];
|
||||
var returnVar = "RDP_DTLS_UPDATE_INSTALLED";
|
||||
var kbInstalledChecker = new KbInstalledChecker(session);
|
||||
kbInstalledChecker.Execute(kb, returnVar);
|
||||
return ActionResult.Success;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,9 +45,9 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="CustomActions.cs" />
|
||||
<Compile Include="KbInstalledChecker.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="InstalledWindowsUpdateGatherer.cs" />
|
||||
<Compile Include="InstalledKbChecker.cs" />
|
||||
<Compile Include="InstalledWindowsUpdateChecker.cs" />
|
||||
<Compile Include="UninstallNsisVersions.cs" />
|
||||
<Content Include="CustomAction.config" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.Deployment.WindowsInstaller;
|
||||
|
||||
namespace CustomActions
|
||||
{
|
||||
public class InstalledKbChecker
|
||||
{
|
||||
private readonly Session _session;
|
||||
private readonly string _kbVariable;
|
||||
private readonly string _returnVar;
|
||||
|
||||
public InstalledKbChecker(string kbVariable, string returnVar, Session session)
|
||||
{
|
||||
_kbVariable = kbVariable;
|
||||
_returnVar = returnVar;
|
||||
_session = session;
|
||||
}
|
||||
|
||||
public bool Execute()
|
||||
{
|
||||
try
|
||||
{
|
||||
_session.Log("Begin InstalledKbChecker");
|
||||
var minimumKb = _session[_kbVariable];
|
||||
var isUpdateInstalled = IsUpdateInstalled(minimumKb);
|
||||
SetReturnValue(isUpdateInstalled);
|
||||
_session.Log("End InstalledKbChecker");
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_session.Log($"There was an issue executing the RdpVersionChecker. Exception: {e}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsUpdateInstalled(string kb)
|
||||
{
|
||||
_session.Log($"Checking if '{kb}' is installed");
|
||||
var updateGatherer = new InstalledWindowsUpdateGatherer();
|
||||
var isUpdateInstalled = updateGatherer.IsUpdateInstalled(kb);
|
||||
_session.Log($"KB is installed = '{isUpdateInstalled}'");
|
||||
return isUpdateInstalled;
|
||||
}
|
||||
|
||||
private void SetReturnValue(bool isUpdateInstalled)
|
||||
{
|
||||
var updateInstalledVal = isUpdateInstalled ? "1" : "0";
|
||||
_session[_returnVar] = updateInstalledVal;
|
||||
_session.Log($"Set property '{_returnVar}' to '{updateInstalledVal}'");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,11 +5,11 @@ using System.Collections.Generic;
|
||||
|
||||
namespace CustomActions
|
||||
{
|
||||
public class InstalledWindowsUpdateGatherer
|
||||
public class InstalledWindowsUpdateChecker
|
||||
{
|
||||
private readonly ManagementScope _managementScope;
|
||||
|
||||
public InstalledWindowsUpdateGatherer()
|
||||
public InstalledWindowsUpdateChecker()
|
||||
{
|
||||
_managementScope = Connect();
|
||||
}
|
||||
@@ -41,10 +41,7 @@ namespace CustomActions
|
||||
return installedUpdates;
|
||||
}
|
||||
|
||||
public bool IsUpdateInstalled(string kb)
|
||||
{
|
||||
return IsUpdateInstalled(new[] {kb});
|
||||
}
|
||||
public bool IsUpdateInstalled(string kb) => IsUpdateInstalled(new[] {kb});
|
||||
|
||||
public bool IsUpdateInstalled(IEnumerable<string> kbList)
|
||||
{
|
||||
44
InstallerProjects/CustomActions/KbInstalledChecker.cs
Normal file
44
InstallerProjects/CustomActions/KbInstalledChecker.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Deployment.WindowsInstaller;
|
||||
|
||||
namespace CustomActions
|
||||
{
|
||||
public class KbInstalledChecker
|
||||
{
|
||||
private readonly Session _session;
|
||||
private readonly InstalledWindowsUpdateChecker _installedUpdateChecker;
|
||||
|
||||
public KbInstalledChecker(Session session)
|
||||
{
|
||||
_installedUpdateChecker = new InstalledWindowsUpdateChecker();
|
||||
_session = session;
|
||||
}
|
||||
|
||||
public bool Execute(string acceptedKb, string returnVar) => Execute(new[] {acceptedKb}, returnVar);
|
||||
|
||||
public bool Execute(IEnumerable<string> acceptedKbs, string returnVar)
|
||||
{
|
||||
try
|
||||
{
|
||||
_session.Log("Begin KbInstalledChecker");
|
||||
var isUpdateInstalled = _installedUpdateChecker.IsUpdateInstalled(acceptedKbs);
|
||||
SetReturnValue(isUpdateInstalled, returnVar);
|
||||
_session.Log("End KbInstalledChecker");
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_session.Log($"There was an issue executing the KbInstalledChecker. Exception: {e}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetReturnValue(bool isUpdateInstalled, string returnVar)
|
||||
{
|
||||
var updateInstalledVal = isUpdateInstalled ? "1" : "0";
|
||||
_session[returnVar] = updateInstalledVal;
|
||||
_session.Log($"Set property '{returnVar}' to '{updateInstalledVal}'");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,8 @@
|
||||
</Property>
|
||||
<Property Id='RDP_DTLS_KB' Value='$(var.RdpDtlsKb)' />
|
||||
<Property Id='RDP_DTLS_UPDATE_INSTALLED' Value='0' Secure='yes' />
|
||||
<Property Id='MINIMUM_RDP_KB' Value='$(var.MinimumRdpKb)' />
|
||||
<Property Id='RDP80_KB' Value='$(var.Rdp80Kb)' />
|
||||
<Property Id='RDP81_KB' Value='$(var.Rdp81Kb)' />
|
||||
<Property Id='MINIMUM_RDP_VERSION_INSTALLED' Value='0' Secure='yes' />
|
||||
<Property Id='REQUIREDDOTNETFRAMEWORKVERSION' Value='$(var.RequiredDotNetFrameworkVersion)' />
|
||||
<Property Id='LEGACYVERSIONINSTALLED' Value='0' />
|
||||
|
||||
Reference in New Issue
Block a user