Поделиться через


How to Configure the Software Distribution Advertised Programs Client Agent Cache

Applies To: System Center Configuration Manager 2007, System Center Configuration Manager 2007 R2, System Center Configuration Manager 2007 R3, System Center Configuration Manager 2007 SP1, System Center Configuration Manager 2007 SP2

In Microsoft System Center Configuration Manager 2007, you configure the cache that is used for downloading programs to a Configuration Manager 2007 client by calling the resource manager (UIResourceMgrClass) object GetCacheInfo method and then by setting the cache properties.

To configure the software distribution advertised programs client agent cache

  1. Get the Configuration Manager client resource manager object (UIResourceMgrClass).

  2. From the UIResourceMgrClass object, call GetCacheInfo to get the client's current cache information.

  3. Set the cache properties as appropriate.

Example

The following example method sets the Configuration Manager client cache location with the supplied path and then displays the cache properties.

For information about calling the sample code, see How to Call Configuration Manager COM Automation Objects.

Sub SetCacheLocation(path)

    On Error Resume Next

    Dim oUIResManager 
    Dim oCache 
    Dim oCacheElements

    Set oUIResManager = createobject("UIResource.UIResourceMgr")

    If oUIResManager Is Nothing Then
        wscript.echo "Couldn't create Resource Manager - quitting"
        Exit Sub
    End If

    Set oCache=oUIResManager.GetCacheInfo()

    If oCache Is Nothing Then
        Set oUIResManager=Nothing
        WScript.Echo "Couldn't get cache info - quitting"
        Exit Sub
    End If
        
    oCache.Location = path
    
    WScript.Echo "Cache information " & oCache.Location

    WScript.Echo "Location: " & oCache.Location
    
    Wscript.Echo "Total size:    " & oCache.TotalSize & " MB"
    WScript.Echo "Free size:     " & oCache.FreeSize & " MB"
    WScript.Echo "Reserved:      " & oCache.ReservedSize & " MB"
    'WScript.Echo "Max Duration: "  & oCache.MaxCacheDuration & " minutes"
   ' Wscript.Echo "TombStone Duration: " & oCache.TombStone.Duration  & " minutes" 
 
     Set oCacheElements=oCache.GetCacheElements

    WScript.Echo "There are " & oCacheElements.Count & " cache elements"
    WScript.Echo

    For Each oCacheElement In oCacheElements
        WScript.Echo "Program Name:    " & oCacheElement.CacheElementID
    Next 
    
    Set oUIResManager=Nothing
    Set oCache=Nothing

End Sub
public void SetCacheLocation(string path)
{
    try
    {
        UIResourceMgrClass uiResMgr = new UIRESOURCELib.UIResourceMgrClass();
        CacheInfo cache = uiResMgr.GetCacheInfo();

        cache.Location = path;

        Console.WriteLine("Location: " + cache.Location);

        Console.WriteLine("Total size:    " + cache.TotalSize.ToString() + " MB");
        Console.WriteLine("Free size:     " + cache.FreeSize.ToString() + " MB");
        Console.WriteLine("Reserved:      " + cache.ReservedSize.ToString() + " MB");
        Console.WriteLine("Max Duration: " + cache.MaxCacheDuration.ToString() + " minutes");
        Console.WriteLine("TombStone Duration: " + cache.TombStoneDuration.ToString() + " minutes");
    }
    catch (COMException e)
    {
        Console.WriteLine("Error setting cache location: " + e.Message);
        throw;
    }
}

The following example method has the following parameters:

Parameter Type Description

path

  • Managed: String

  • VBScript: String

  • The path to the new cache location.

Compiling the Code

This C# example requires:

Namespaces

System

System.Collections.Generic

System.Text

System.Runtime.InteropServices

UIRESOURCELib

COM Reference

UIResource 1.0 Type Library

Robust Programming

For more information about error handling, see About Configuration Manager Errors.

Security

For more information about securing Configuration Manager applications, see About Securing Configuration Manager Applications.

See Also

Concepts

About Configuration Manager Client Configuration
Configuration Manager Client Configuration
How to Get and Set the Current Management Point for a Configuration Manager Client
SmsClient Client COM Automation Class
How to Call Configuration Manager COM Automation Objects