Skip the navigation

Hands On: Learning Monad, the scripting language for Windows Vista

Microsoft lead programmer Andy Oakley looks at the next-generation MSH Windows Command Shell

By Andy Oakley
January 17, 2006 12:00 PM ET

Computerworld -

Part 1: Introducing Monad, the MSH Command Shell
Part 2: Access the Registry Like a Filesystem
Part 3: Souped-up Pipeline
Part 4: Displaying data with Monad
Excerpted from Monad with permission of O'Reilly Media Inc., all rights reserved. The first of four parts.
Introducing Monad, the MSH Command Shell
Monad, also known more formally as the MSH Command Shell, is a next generation Windows command shell. Built on top of the .NET Framework, MSH provides a powerful infrastructure for the automation of a wide range of administrative tasks. At last, the command line is a first-class citizen in the world of Windows system management.
It would be unfair to characterize MSH as simply an evolution of the cmd.exe shell, a system whose roots reach back to the days of MS-DOS and before. Indeed, although the standard "host" of MSH is a console application, MSH is designed so that it can be used in other contexts, such as the MMC (Microsoft Management Console). This new shell is built from the ground up with a focus on structured data and today's administrative challenges.
The pipeline, a mechanism for passing data between different functional units, has long been a feature of many shells, including cmd.exe. MSH goes beyond the traditional notion of using text to pass data between the different stages of the pipeline and all of the "prayer-based parsing" that goes with it by allowing the transfer of structured data in the form of .NET objects between the pipeline elements. This self-describing information can be used at any point in a complex sequence and allows any process to operate on data in an intelligent fashion, even pipeline elements that have never seen a given type of data before.
MSH also uses a provider model so that the many types of hierarchical data stores used with Windows systems can be accessed through a single consistent set of commands. In MSH, the mechanism for retrieving folders, files, content, and the current location applies not only to filesystems but also to other stores, such as the registry.
Repeatability and consistency are the two words that capture some of the real value of using MSH. Administering a single machine today is a simple task; Windows offers a well-organized graphical interface for settings and configuration, and Terminal Services makes it easy to effect changes on a server located on the other side of the world. Unfortunately, in simple terms, this model doesn't scale well at all; it takes twice as long to manage 2 machines and 10 times as long for 10.
Fortunately, there are management tools such as Systems Management Server (SMS) that ease this burden across the enterprise. Also, technologies such as WSH (Windows Scripting Host) and Perl can be used to automate repetitive tasks. By offering a scriptable language, MSH offers yet another alternative to the manual click-by-click sequence where a one-time investment in authoring a configuration script enables quick replay on a potentially large number of machines with predictable results. Add this all up, and there's a lot of time to be saved.

Part 1: Introducing Monad, the MSH Command Shell
Part 2: Access the Registry Like a Filesystem
Part 3: Souped-up Pipeline
Part 4: Displaying data with Monad
Let's take a moment to dispel a few rumors about MSH. The new shell is not a programming language to be compared with C#, C++, or VB.NET, yet it does offer a powerful scripting language. Although MSH relies heavily on the .NET Framework, it is first and foremost an administrative tool. As we'll see, MSH is a hybrid, taking the idea of a command shell and combining it with a rich scripting language to form something altogether more useful. MSH isn't going to replace everything in a system manager's toolbox either; in fact, think of MSH as a conduit that provides easy access to pre-existing components whether they are exposed through the .NET Framework, COM objects, or some other mechanism. cmd.exe isn't going away either; MSH even offers support for other command-line utilities that process text. The existing command-line toolset will continue to live, and investments made in console-based applications remain valuable. Finally, MSH is not positioned to encroach on the realm of software builds. While it offers a number of features useful in a large build environment, it's a complement to NMAKE, MSBuild, or Visual Studio Team System, rather than a drop-in replacement for them.
These are just a few of the features of MSH that are causing Windows system administrators to take notice. As a shell, it brings together some powerful concepts by leveraging the .NET Framework and COM, and by allowing existing tools to be reused rather than reinvented. As we'll soon see, a tool like this has a very wide range of uses.
MSH is supported on a number of currently available Microsoft operating systems. To use MSH, you'll need to be running on one of the following platforms:
  • Microsoft Windows XP SP2

  • Microsoft Windows Server 2003 SP1

  • Microsoft Windows Vista (formerly Windows Code Name "Longhorn")

In addition to a supported operating system, MSH requires the .NET Framework 2.0 redistributable, SDK, or Visual Studio 2005.
Downloading MSH
Everything needed to get up and running can be downloaded from the Web. Follow these installation steps and you'll be ready to go:
1. Download and install the .NET Framework 2.0 Redistributable from Several versions are available for different machine architectures (32-bit and 64-bit); pick the one suitable for your machine.
2. Go to and search for "Monad". Download and install the latest release.
That's it. Let's get started!
Get to Know Verb-Noun Syntax and Cmdlets
We'll begin by getting the shell up and running so that we can start to put MSH through its paces. This section will focus on the time-honored task of inspecting the process list to see what's currently running on a system. There are some MSH features that may not be immediately familiar to those in other command shells-in particular, the strict command syntax-but we'll also look at a few of the obvious differences and see how they're really nothing to fear.
These basics show you how to start using the shell, and they provide the foundation for the rest of the examples we'll cover.
How Do I Do That?
Most MSH commands are identified by a pair of words, one verb and one noun, separated by a hyphen. The verb describes the action (such as get or set) while the noun represents the target of the action in singular form (such as process or location). There is a standard list of verbs that covers the majority of tasks (including get, set, add, and remove). Although the number of these verbs may seem excessively large, consistent naming does make learning and using MSH easier in the long run.
There's Nothing Like Experience

Our Commenting Policies