In Microsoft System Center Configuration Manager 2007, a folder is deleted by deleting its associated SMS_ObjectContainerNode Server WMI Class object. The folder is identified by the SMS_ObjectContainerNode.ContainerNodeID property.

Note
The console folders provide a view into the items they contain. When a folder is deleted, any folders and items that it contains are not deleted; rather, they are moved to the root folder.

To delete a console folder

  1. Set up a connection to the SMS Provider. For more information, see About the SMS Provider in Configuration Manager.

  2. Get the SMS_ObjectContainerNode object instance for the console folder you want to delete.

  3. Call the connection object Delete method to delete the console folder.

Example

The following example deletes a folder identified by its node identifier (nodeID).

For information about calling the sample code, see Calling Configuration Manager Code Snippets.

Visual Basic Script  Copy Code
Sub DeleteConsoleFolder(connection, nodeID)

	Dim folder

	Set folder = connection.Get("SMS_ObjectContainerNode.ContainerNodeID=" + CStr(nodeID) + "")
	folder.Delete_
		
End Sub
C#  Copy Code
public void DeleteConsoleFolder(WqlConnectionManager connection, Int32 nodeID)
{
	try
	{
		IResultObject folder = connection.GetInstance(@"SMS_ObjectContainerNode.ContainerNodeID=" + nodeID + "");
		folder.Delete();
}
	catch (SmsException e)
	{
		Console.WriteLine("Failed to delete package. Error: " + e.Message);
		throw;
}
}

The example method has the following parameters:

Parameter Type Description

connection

  • Managed: WqlConnectionManager

  • VBScript: SWbemServices

A valid connection to the SMS Provider.

nodeID

  • Managed: Int32

  • VBScript: String

The identifier for the console folder. For more information, see the SMS_ObjectContainerNode class ContainerNodeID property.

Compiling the Code

This C# example requires:

Namespaces

System

System.Collections.Generic

System.Text

Microsoft.ConfigurationManagement.ManagementProvider

Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine

Assembly

microsoft.configurationmanagement.managementprovider

adminui.wqlqueryengine

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.