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.


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.

Visual Basic Script  Copy Code
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"

	For Each oCacheElement In oCacheElements
		WScript.Echo "Program Name:	" & oCacheElement.CacheElementID

	Set oUIResManager=Nothing
	Set oCache=Nothing

End Sub
C#  Copy Code
public void SetCacheLocation(string path)
		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);

The following example method has the following parameters:

Parameter Type Description


  • Managed: String

  • VBScript: String

  • The path to the new cache location.

Compiling the Code

This C# example requires:







COM Reference

UIResource 1.0 Type Library

Robust Programming

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


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

See Also

Send comments about this topic to Microsoft.