MMC 2.0 Automation Object Model
Microsoft Management Console (MMC) 2.0 includes the first release of the MMC automation object model architecture for snap-in and extension developers. The MMC 2.0 automation object model may also be used by developers who do not want to write snap-ins or extensions, but who would like to write programs that interact with MMC.
MMC 2.0 contains the following new objects.
|AppEventsDHTMLConnector Object||Object that provides a means for automation clients to receive events from MMC; this object is used by scripts running on DHTML pages created by view extensions. For more information about view extensions, see Extending Views.|
|Application Object||The MMC 2.0 application object, which can be used to access other MMC 2.0 automation objects.|
|Column Object||Result pane column object.|
|Columns Collection||Collection of Column objects.|
|ContextMenu Object||MMC context menu object.|
|Document Object||MMC console document object.|
|Extension Object||MMC snap-in extension.|
|Extensions Collection||Collection of Extension objects.|
|Frame Object||MMC console frame object; this object encapsulates the MMC main window.|
|MenuItem Object||MMC menu item object.|
|Node Object||MMC node object.|
|Nodes Collection||Collection of Node objects.|
|Properties Collection||Collection of Property objects.|
|Property Object||MMC property object.|
|ScopeNamespace Object||MMC namespace object.|
|SnapIn Object||MMC snap-in object.|
|SnapIns Collection||Collection of SnapIn objects.|
|View Object||MMC view object. This object serves as the external object when an MMC snap-in hosts Microsoft Internet Explorer components.|
|Views Collection||Collection of View objects.|
When a script is executed, a call to an MMC object model interface may generate a run-time error that halts execution of the script. As a good coding practice, you should use the error handling mechanism of your script language to handle these errors. For example, VBScript provides the "on error resume next" statement for handling errors inline.
When adapting VBScript example code for use in your own working environment, inserting an "on error resume next" statement in each procedure helps trap errors that may otherwise halt script execution. An error code "err" can then be inspected immediately after a script statement that causes a run-time error. To clear the value in "err", use the VBScript "err.clear" command. For more information about using "on error" statements in VBScript, see the VBScript User's Guide.
For example, use the following code to trap an execution error caused by a non-existent snap-in:
on error resume next objMMC.Document.SnapIns.Add("Folder1") `if a Snap-in does not exist MMC throws an error if err then `Trap the error just after the statement where an error/exception can occur and handle it elegantly msgbox("Snap-in Not found") err.clear end if
To trap an exception caused when a node child is not found for a scope node, use the following code:
Function ScopeNodeHasChild(ScopeNamespace, SampleNode) on error resume next ScopeNamespace.Expand(SampleNode) set NodeFound = ScopeNamespace.GetChild(SampleNode) if err then ScopeNodeHasChild = false exit function `Return False when there are no child nodes for the scope node. end if ScopeNodeHasChild = true `Return True when a child node is found. End Function
- Getting Started with the Automation Object Model
- Using the Extended View Extension - Implementation Details
Build date: 10/15/2013