mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 22:11:48 +08:00
42 lines
1.5 KiB
C#
42 lines
1.5 KiB
C#
using Microsoft.Deployment.WindowsInstaller;
|
|
|
|
namespace CustomActions
|
|
{
|
|
public class RdpVersionChecker
|
|
{
|
|
private readonly Session _session;
|
|
private const string MinimumVersionInstalledReturnVar = "MINIMUM_RDP_VERSION_INSTALLED";
|
|
private const string MinimumRdpKbVariable = "MINIMUM_RDP_KB";
|
|
|
|
public RdpVersionChecker(Session session)
|
|
{
|
|
_session = session;
|
|
}
|
|
|
|
public bool Execute()
|
|
{
|
|
_session.Log("Begin IsMinimumRdpVersionInstalled");
|
|
var minimumKb = _session[MinimumRdpKbVariable];
|
|
var isUpdateInstalled = IsUpdateInstalled(minimumKb);
|
|
SetReturnValue(isUpdateInstalled);
|
|
_session.Log("End IsMinimumRdpVersionInstalled");
|
|
return true;
|
|
}
|
|
|
|
private bool IsUpdateInstalled(string minimumKb)
|
|
{
|
|
_session.Log("Checking if '{0}' is installed", minimumKb);
|
|
var updateGatherer = new InstalledWindowsUpdateGatherer();
|
|
var isUpdateInstalled = updateGatherer.IsUpdateInstalled(minimumKb);
|
|
_session.Log("KB is installed = '{0}'", isUpdateInstalled);
|
|
return isUpdateInstalled;
|
|
}
|
|
|
|
private void SetReturnValue(bool isUpdateInstalled)
|
|
{
|
|
var updateInstalledVal = isUpdateInstalled ? "1" : "0";
|
|
_session[MinimumVersionInstalledReturnVar] = updateInstalledVal;
|
|
_session.Log($"Set property '{MinimumVersionInstalledReturnVar}' to '{updateInstalledVal}'");
|
|
}
|
|
}
|
|
} |