Skip to main content

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 http://www.microsoft.com/downloads/details.aspx?FamilyID=0baf2b35-c656-4969-ace8-e4c0c0716adb&DisplayLang=en

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 http://sourceforge.net/projects/mmclibrary

The MMC 3.0 application installation is at http://www.microsoft.com/downloads/details.aspx?FamilyID=61fc1c66-06f2-463c-82a2-cf20902ffae0&DisplayLang=en

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 http://www.microsoft.com/downloads/details.aspx?FamilyID=61fc1c66-06f2-463c-82a2-cf20902ffae0&DisplayLang=en
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

Installation
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
C:\MySnapinProject\bin\Debug\ManagementConsoleSnapin.dll

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.


Comments

vtortola said…
Hi!

I'm trying to install a MMC with a Setup Project ... but I can't get it.

With InstallUtil.exe runs fine, but with a Setup Project does't appear in the snap-in list of mmc.exe.

What is the good way to do it?

Thanks in advance.

Kind regards.
learnerplates said…
Veleriano,
Welcome, I hope some of my posts are of use to you.

I'll presume we're talking about MMC 3.0.

How are calling the MMC installation from your Setup Project? Have you just added it as a project output? Or maybe a Custom Task?

Have you MMC 3.0 installed on the a machine that you are running the installer (If not and you have mmc 2.0 you'll not see your snapin in the list).

LP.

Popular posts from this blog

BootStrapper BootStrapping

Bootstrapping is the creation of a wrapper installer around already existing installars or files. It's useful if you have multiple installation files that you'll like the user to install in on step. The Bootstrapper itself is a .exe installer file, it also may have .SED file which contains details of the contents of the .exe. There are a few applications out there to generate a bootstrapper, the most simple I've seen is the an app called IEXpress . IExpress Is actually installed on windows (System32/iexpress.exe). This creates an installer, you tell it what files you wish it to include in the installation. I've only played with this so far and it appears to me that the isntaller can only install upto 2 setup.exes. You can include as many files as you like, but the files cannot have the same name, because of this you will probably need to rename your setup.exes to something else because you cannot have 2 files with the same name. After you've included all the files...

Installer CustomAction, Debugging the CustomAction, InstallState

Custom Action The Custom Action is added to the Setup Project, select the Project node and hit the Custom Action button. This allows you add an Action to a particular phase in the Installation. But first you must create the Custom Action. To Add a Custom Action you must first have a Custom Action created, this is usually in the form of a Installer Class, this should be created in a seperate project, the Installer Class is actually one of the File Templates in the C# Projects. So it's File->New Project and select Visual C# Projects. Then add a Class Library, this will prompt you for the Class Library Types , select "Installer Class". Walkthrough - Creating Custom Action (msdn). Also here's a more comprehensive document on Setup/Installer implementations, it delves into the Registry etc Getting Started with Setup Projects (SimpleTalk). Visual Studio Setup Projects and Custom Actions (Simple Talk). Create your Installer Class and then add it as a Custom Action to the ...

dotNET - Use app.config ApplicationSettings and UserSettings

When using Settings in an Assembly or .exe you can use the Settings Designer to generate a config file using Settings. The Settings Designer provides a wrapper class which allows you to provide defaults and access the config data using Properties. But what if you're not working inside that Assembly or .exe? this presents a problem. If your loading the Assembly externally and want to access that Assembly's .config file you'll probably wish to use something in the System.Configuration namespace... unfortunately it's not of much use if you've created the .config file from the Settings Designer in Visual Studio!! This is because the Designer creates Sections and ApplicationSettings and UserSettings, the System.Configuration namespace does not provide a method to access these (it has a method to access AppSettings which are a different thing. Below I've written a workaround which locates the app.config and accesses the ApplicationSettings and UserSettings using XML i...