In Microsoft System Center Configuration Manager 2007, you view the available programs on a Configuration Manager 2007 client by using the resource manager (UIResourceMgrClass) object GetAvailableApplication method to get a Programs collection.

To view the available programs on a Configuration Manager client

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

  2. From the UIResourceMgrClass object, call GetAvailableApplications to get a Programs collection of available programs.

  3. Loop through the Programs collection to display each Program.

Example

The following example method displays a list of available programs.

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

Visual Basic Script  Copy Code
Sub ShowPrograms

	On Error Resume Next

	Dim oUIResource 
	Dim oPrograms 
	Dim oProgram 

	Set oUIResource = CreateObject ("UIResource.UIResourceMgr")

	If oUIResource Is Nothing Then 
		wscript.echo "Could not create Resource Object - quitting"
		Exit Sub
	End If

	Set oPrograms = oUIResource.GetAvailableApplications

	If oPrograms Is Nothing Then
		wscript.echo "Failed to get programs object - quitting"
		Set oUIResource=Nothing
		Exit Sub
	End If

	wscript.echo "There are " & oPrograms.Count & " programs"
	wscript.echo

	For Each oProgram In oPrograms
		WScript.Echo "Program Name: " & oProgram.FullName
		WScript.Echo "  Comments:   " & oProgram.Comments
		WScript.Echo "  Package ID: " & oProgram.PackageId
		WScript.Echo 
	Next 

	Set oProgram=Nothing
	Set oUIResource=Nothing

End Sub
C#  Copy Code
public void ShowPrograms()
{
	try
	{
		UIResourceMgrClass uiResMgr = new UIRESOURCELib.UIResourceMgrClass();
		Programs progs = uiResMgr.GetAvailableApplications();

		Console.WriteLine("There are " + progs.Count + " programs");
		Console.WriteLine();
	
		foreach (ProgramCls prog in progs)
		{
			Console.WriteLine("Program Name: " + prog.FullName);
			Console.WriteLine("  Comments: " + prog.Comments);
			Console.WriteLine("  Program ID: " + prog.Id);
			Console.WriteLine("  PackageID: " + prog.PackageId);
	}
}
	catch (COMException e)
	{
		Console.WriteLine("Exception occurred: " + e.Message);
		throw;
}
}

The example method has no parameters.

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


Send comments about this topic to Microsoft.