November 27, 2007

MMC Snapin creation

MMC Snapin Creation

There are 2 main versions of MMC available on Windows, MMC 2.0 (Windows 2000 and XP) and MMC 3.0 (Windows Server 2003). I'll mainly explain how to develop a Snap-in with MMC 3.0.

You can upgrade MMC 2.0 to MMC 3.0 using this install supplied by Microsoft

MMC 2.0 snapin:
Download the Platform SDK, Windows® Server 2003 R2 Platform SDK Web Install, from

Build an example from the Platform SDK install:
C:\Program Files\Microsoft Platform SDK\Samples\SysMgmt\MMC\mmc2.0\simple>nmake

MMC 3.0 snapin:

How to Develop and MMC 3.0 Snap-in (msdn)

How to create a Snap-in using MMC 3.0 (msdn)

MMC Snap-ins for MMC 3.0 can be developed with the Windows SDK, for information on the snapin classes see msdn Management Console
There is also an opensource .NET library at

The MMC 3.0 application installation is at

Here's an example of how to build a simple Snapin

To develop MMC 3.0 snapins you'll need the microsoft.managementconsole.dll library. This library can be gotten by installing the MMC 3.0, found at
Add this library as a reference to your Snapin project and you'll have access to it's functionality.

You can also install the Windows Server 2003 R2 Service pack. Some example code is available on the web.

You Snapin is a Class Library project. It's main Class should implement the Microsoft.ManagementConsole.SnapInInstaller interface and override these 3 methods

public override void Install(IDictionary stateSaver);
public override void Rollback(IDictionary savedState);
public override void Uninstall(IDictionary savedState);

MMC 3.0 - A managed code 'task manager' MMC 3.0 snap-in

The procedure to install the MMC Snapin in MMC 2.0 and MMC 3.0 is different, see below for further details:

MMC 2.0 snapin:

Register the snapin with MMC:
C:\Program Files\Microsoft Platform SDK\Samples\SysMgmt\MMC\mmc2.0\simple\WIN2000_DEBUG>regsvr32 Simple.dll

MMC 3.0 Snapin
This snapin was build with MMC 3.0 as ManagementConsoleSnapin.dll

The resultant DLL, C:\MySnapinProject\bin\Debug\ManagementConsoleSnapin.dll, can be installed as a snapin to MMC 3.0 as follows: >C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\installutil.exe C:\MySnapinProject\bin\Debug\ManagementConsoleSnapin.dll

and uninstalled using:
>C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\installutil.exe /u

After installation the snapin appears in the MMC Snapin list as "My Management Console". Add the snapin to MMC and select OK. The Snapin is now ready for use.

MMC Snapin Debugging
The easiest way to debug the MMC while installing the Snapin is to set the Project Properties of your snapin project, in the project properties Debug tab select 'Start External Program' and enter 'C:\WINDOWS\system32\mmc.exe' in the field. Now when you hit F5 the MMC app will launch, you now 'Add\Remove Snapin' from the MMC's File menu.