Manually Approving Updates for Deployment

 

Applies To: Windows Server Update Services

To approve an update for deployment, call IUpdate.Approve(UpdateApprovalAction, IComputerTargetGroup). The update approval action indicates if you want to install the update on a client computer, scan the client computer to determine if the update is applicable, remove the update from the client, prevent the update from deploying to a specific target group, or specify that the update use the same approval action as its parent.

Before approving an update for installation, you should first call IUpdate.RequiresLicenseAgreementAcceptance to determine if the user must first accept a license agreement before approving the update. To accept the license agreement, call IUpdate.AcceptLicenseAgreement().

If the update is a revision to a previous update, you can call IUpdate.RefreshUpdateApprovals() to apply the previous revision's approval to the latest revision. If you always want to apply the current approval to the latest revision of an update, set IUpdateServerConfiguration.AutoRefreshUpdateApprovals to true.

You can approve different revisions of the same update for deployment to different groups; however, if one of the groups is the All Computers group, the approval actions cannot conflict (for example, you cannot approve one revision for installation and the other revision for removal). You cannot approve different revisions of an update for deployment to the same group.

To determine if the update is a revision to a previous update, call IUpdate.HasEarlierRevision. To determine if a previous revision of the update contains an approval, call IUpdate.HasStaleUpdateApprovals. To determine if the update is the latest revision of the update, call IUpdate.IsLatestRevision.

The following example shows how to approve an update for installation to the All Computers group. The update variable is an instance of IUpdate. The server variable is an instance of IUpdateServer.

bool okToApprove = true;
string response;

if (update.RequiresLicenseAgreementAcceptance)
{
  ILicenseAgreement eula = update.GetLicenseAgreement();

  //If EULA is not already accepted, display text and wait for a response.
  if (false == eula.IsAccepted)
  {
    Console.WriteLine(eula.Text);
    Console.Write("\n\nDo you accept the terms of the agreement, \"Yes\" or \"No\": ");
    response = Console.ReadLine();
    if ("yes" = response.ToLower())
      update.AcceptLicenseAgreement();
    else
      okToApprove = false;
  }
}

if (true == okToApprove)
{
  update.Approve(UpdateApprovalAction.Install, server.GetComputerTargetGroup(ComputerTargetGroupId.AllComputers));
}

For information on automatically approving updates, see Defining Automatic Approval Rules.