ISubscription.SynchronizeAutomaticallyTimeOfDay

Retrieves or sets the time of day when the WSUS server automatically synchronizes the updates.

public TimeSpan SynchronizeAutomaticallyTimeOfDay {get; set;}
Public Property SynchronizeAutomaticallyTimeOfDay As TimeSpan

Property Value

Time of day when the WSUS server automatically synchronizes the updates. Specify the value as a time span since midnight. Express the time in Coordinated Universal Time (UTC). The smallest allowable unit of time is a second—fractions of a second will be truncated.

Exceptions

Exception type Condition
ArgumentOutOfRangeException The time span cannot be greater than or equal to 24 hours or set to a negative time value.

Remarks

The time of day value is used only if ISubscription.SynchronizeAutomatically is true.

Note  WSUS stores the time in Coordinated Universal Time. This can affect the local time value that you display. For example, if the user wants the server to synchronize at 03:00 local time in a standard time zone that is 8 hours west of Coordinated Universal Time, you would set this property to 11:00 Coordinated Universal Time. When daylight saving time occurs, the server will continue to synchronize at 11:00 Coordinated Universal Time, however the local time value of this property will be 04:00.

Example Code

The following example shows how to set SynchronizeAutomaticallyTimeOfDay. The server variable that is used in the example is an instance of IUpdateServer (for information on retrieving an IUpdateServer instance, see Using WSUS).

ISubscription subscription = server.GetSubscription();

subscription.SynchronizeAutomatically = true;

//Synchronize updates automatically at 4:30 every morning.
DateTime localSyncHour = DateTime.Today + new TimeSpan(4,30,0);

//WSUS stores dates and times in Coordinated Universal Time, 
//so convert the local time to Coordinated Universal Time.
subscription.SynchronizeAutomaticallyTimeOfDay = localSyncHour.ToUniversalTime().TimeOfDay;
subscription.Save;

Example Code

The following example shows how to retrieve SynchronizeAutomaticallyTimeOfDay. The server variable that is used in the example is an instance of IUpdateServer (for information on retrieving an IUpdateServer instance, see Using WSUS).

ISubscription subscription = server.GetSubscription();

//WSUS stores dates and times in Coordinated Universal Time. 
//Convert the Coordinated Universal Time to local time and
//display the string.
DateTime syncHour = DateTime.Today + subscription.SynchronizeAutomaticallyTimeOfDay;
Console.WriteLine("Synchronize at {0} every day.", syncHour.ToLocalTime().ToShortTimeString());

Requirements

Server Requires Windows Server 2003 or Windows 2000 Server SP4 and later.
Namespace

Defined in Microsoft.UpdateServices.Administration.

Assembly

Requires Microsoft.UpdateServices.Administration (in Microsoft.UpdateServices.Administration.dll).

.NET Framework

Requires .NET Framework 1.1.

See Also

ISubscription.GetNextSynchronizationTime