In Microsoft System Center Configuration Manager 2007, you run a Configuration Manager 2007 client action by calling the PerformAction method on the actions retrieved by CPAppletMgr object GetClientActions method.
To run a Configuration Manager client action
-
Get the Configuration Manager client Control Panel manager object (CPAppletMgr).
-
From CPAppletMgr, call GetClientActions to retrieve a collection of Configuration Manager client actions.
-
Loop through the collection and call PerformAction for each action you want to perform.
Example
The following example method gets the Configuration Manager client actions and performs each one by calling PerformAction.
For information about calling the sample code, see How to Call Configuration Manager COM Automation Objects.
Visual Basic Script | Copy Code |
---|---|
Sub PerformAction On Error Resume Next Dim oCPAppletMgr ' Control Applet manager object Dim oClientAction ' Individual client action Dim oClientActions ' A collection of client actions ' Get the Control Panel applet manager object. Set oCPAppletMgr=CreateObject("CPApplet.CPAppletMgr") If err.number <> 0 Then Wscript.echo "Couldn't create control panel application manager" Exit Sub End If ' Get a collection of actions. Set oClientActions=oCPAppletMgr.GetClientActions If err.number<>0 Then wscript.echo "Couldn't get the client actions" Set oCPAppletMgr=Nothing Exit Sub End If ' Display each client action name and perform it. For Each oClientAction In oClientActions wscript.echo oClientAction.name oClientAction.PerformAction wscript.echo Next Set oClientActions=Nothing Set oCPAppletMgr=Nothing End Sub |
C# | Copy Code |
---|---|
public void PerformAction() { try { CPAppletMgr cpAppletMgr = new CPAppletMgr(); ClientActions clientActions = cpAppletMgr.GetClientActions(); foreach (ClientAction action in clientActions) { Console.WriteLine("Name: " + action.Name); action.PerformAction(); Console.WriteLine(); } } catch (COMException e) { Console.WriteLine("Error performing actions: " + 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
CPAPPLETLib
Assemblies
CPApplet 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
Tasks
How to View the Configuration Manager Client ComponentsHow to View the Configuration Manager Client Properties
Concepts
About Configuration Manager Control Panel ConfigurationHow to Call Configuration Manager COM Automation Objects
Other Resources
Configuration Manager Client Control Panel ConfigurationSend comments about this topic to Microsoft.