in src/PatchOrchestrationApplication/NodeAgentNTService/src/Manager/TimerManager.cs [115:169]
private void DisableWindowsUpdate()
{
CheckpointFileData fileData = this.ReadCheckpointFile();
DateTime initialTime = DateTime.Now;
if (!fileData.lastAttemptedUpdateTime.Equals(_checkpointFileDefaultDateTime))
{
initialTime = fileData.lastAttemptedUpdateTime;
}
long timeToLive = (long)((fileData.schedulingDateTime - initialTime) + TimeSpan.FromDays(1)).TotalMinutes;
if (!this._serviceSettings.DisableWindowsUpdates)
{
_eventSource.InfoMessage("Not disabling automatic windows updates.");
return;
}
_eventSource.InfoMessage("Disabling automatic windows updates.");
do
{
string msg = "Not able to disable the 'Windows Updates'. ";
try
{
WindowsAutoUpdateUtility auUtility = new WindowsAutoUpdateUtility();
if (auUtility.IsWindowsServer2012R2OrLower())
{
_eventSource.InfoMessage("Detected OS version is Windows Server 2012R2 or lower");
AutomaticUpdatesClass updates = new AutomaticUpdatesClass();
_eventSource.InfoMessage("Current automatic windows updates notification level {0}.", updates.Settings.NotificationLevel);
auUtility.DisableAUThroughWUApi(updates);
}
else
{
_eventSource.InfoMessage("Detected OS version is higher than Windows Server 2012R2");
_eventSource.InfoMessage("Current AU registry values are {0}", auUtility.LogCurrentAUValues());
auUtility.SetAUOptions();
_eventSource.InfoMessage("New AU registry values are {0}", auUtility.LogCurrentAUValues());
}
string updateMsg = "Windows Update policy has been configured to Notify before Download";
this._nodeAgentSfUtility.ReportHealth(WUOperationSetting, updateMsg, HealthState.Ok, timeToLive, TimeSpan.FromMinutes(this._serviceSettings.OperationTimeOutInMinutes));
return;
}
catch (Exception e)
{
msg = string.Format(msg + "Failing with exception : {0}", e);
}
_eventSource.WarningMessage(msg);
this._nodeAgentSfUtility.ReportHealth(WUOperationSetting, msg, HealthState.Warning, -1, TimeSpan.FromMinutes(this._serviceSettings.OperationTimeOutInMinutes));
this._helper.WaitOnTask(Task.Delay(TimeSpan.FromMinutes(WaitTimeInMinutes)), this._cancellationToken);
} while (true);
}