IT tutorials
Applications Server

BizTalk Server 2009 : Administrative Tools (part 2) - WMI

1/5/2013 11:50:04 AM
- Windows 10 Product Activation Keys Free 2019 (All Versions)
- How To Bypass Torrent Connection Blocking By Your ISP
- How To Install Actual Facebook App On Kindle Fire

3. WMI

Windows Management Instrumentation provides a standard way of managing a computer system. WMI allows you to

  • Gather information about systems.

  • Configure systems.

  • Fire or consume specific WMI events occurring on c = omputers or servers.

Tables 11 and 12 describe the different BizTalk WMI classes and events. To utilize these classes, you must use the WMI COM API or the System.Management assembly, which is a .NET COM Interop assembly. Listing 1 demonstrates how to create a host using WMI API from managed code.

Table 11. BizTalk WMI Classes
WMI Class NameSpecific MethodsPurpose
MSBTS_AdapterSettingNoneRegisters new adapters.
MSBTS_DeploymentServiceDeploy, Export, Import, RemoveDeploys/undeploys assemblies and imports/exports binding files.

Represents information about BTS Groups.
MSBTS_HostStart, StopRepresents a host. Used to start/stop all host instances in a given BizTalk host. It is also used to get/set host properties.
GetState, Install, Start, Stop,

Represents a host instance. Used to install/uninstall and start/stop a specific host instance in a given BizTalk host.
MSBTS_HostInstanceSettingNoneRepresents host settings.

Resumes, suspends, or terminates service instances.
MSBTS_HostSettingNoneSets host settings.
MSBTS_MessageInstanceSaveToFileRepresents a message instance.
MSBTS_MsgBoxSettingForceDeleteRepresents a single Messagebox setting in the BizTalk Server Group.
Enlist, QueryDependencyInfo,
QueryInstanceInfo, Start,
Stop, Unenlist

Represents an orchestration. Used to start/stop and enlist/unenlist orchestrations.
MSBTS_ReceiveHandlerNoneRepresents a receive handler. Used to configure receive handlers.
MSBTS_ReceiveLocationDisable, EnableRepresents a receive location. Used to enable and disable the receive location.

NoneRepresents all possible combinations of orchestrations and receive locations.
MSBTS_ReceivePortNoneRepresents a receive port. Used to configure receive ports.
MSBTS_SendHandlerNoneRepresents a send handler. Used to configure send handlers.
MSBTS_SendPortEnlist, Start, Stop, UnenlistRepresents a send port. Used to configure send ports.
MSBTS_SendPortGroupEnlist, Start, Stop, UnEnlistRepresents a send port group. Used to start/stop and enlist/unenlist send port groups.

NoneRepresents a many-to-many relationship between send port groups and send ports.
MSBTS_ServerCheckIfCanInstallHost Instances, Start, StopRepresents a computer within a BizTalk Server Group. Used to start services on a given server.
MSBTS_ServerHostForceUnmap, Map, UnmapRepresents a mapping between BizTalk hosts and host instances. Used to map and unmap relationships.
MSBTS_ServiceInstanceResume, Suspend, TerminateRepresents an instance of a service. Used to resume, suspend, and terminate services.

SaveToFileRepresents a tracked message instance saved in the Messagebox or Archive databases. Used to save a message to a file.

Table 12. BizTalk WMI Events
WMI Event NameSpecific PropertiesPurpose

ErrorCategory, ErrorDescription,
ErrorId, HostName, Message
InstanceID, MessageType,
ReferenceType, ServiceClass,
ServiceClassID, Service
InstanceID, ServiceTypeID

Represents a suspended event for a BizTalk Message Queuing (MSMQT) message instance

ErrorCategory, ErrorDescription,
ErrorId, HostName, InstanceID,
ServiceClass, ServiceClassID,
ServiceStatus, ServiceTypeID

Represents a suspended event for a service instance

Example 1. Create Host Example Using Managed Code
using System.Management;

      // Basic WMI operation - Create
      // sample to show MSBTS_HostSetting instance creation
      public void CreateHost(string ServerName, string HostName, int HostType,
string NTGroupName, bool AuthTrusted)
            PutOptions options = new PutOptions();
            options.Type = PutType.CreateOnly;

            // Create a ManagementClass object and spawn a ManagementObject instance
            ManagementClass objHostSettingClass = new ManagementClass("\\\\" +
ServerName + "\\root\\MicrosoftBizTalkServer", "MSBTS_HostSetting", null);
            ManagementObject objHostSetting = objHostSettingClass.CreateInstance();

            // Set the properties for the Host
            objHostSetting["Name"] = HostName;
            objHostSetting["HostType"] = HostType;
            objHostSetting["NTGroupName"] = NTGroupName;
            objHostSetting["AuthTrusted"] = AuthTrusted;

            // Creating the host
            System.Console.WriteLine(string.Format("The Host '{0}'has been
created successfully", HostName ));
         catch(Exception ex)


            System.Console.WriteLine("CreateHost - " + HostName +
" - failed: " + ex.Message);

The same example using VBScript instead of managed code is shown in Listing 2.

Example 2. Create Host Example Using VBScript
Option Explicit
' wbemChangeFlagEnum Setting
const UpdateOnly = 1
const CreateOnly = 2
Sub CreateHost (ServerName, HostName, HostType, NTGroupName, AuthTrusted)
   On Error Resume Next
   Dim objLocator, objService, objHostSetting, objHS

   ' Connects to local server WMI Provider BizTalk namespace
   Set objLocator = Createobject ("wbemScripting.SwbemLocator")
   Set objService = objLocator.ConnectServer(ServerName,

   ' Get WMI class MSBTS_HostSetting
   Set objHostSetting = objService.Get ("MSBTS_HostSetting")

   Set objHS = objHostSetting.SpawnInstance_

   objHS.Name = HostName
   objHS.HostType = HostType
   objHS.NTGroupName = NTGroupName
   objHS.AuthTrusted = AuthTrusted

   ' Create Host

   wscript.echo "Host - " & HostName & " - has been created successfully"
end Sub


Another interesting task you can accomplish with WMI is to subscribe to MSTBS_MessageInstanceSuspendentEvent and MSTBS_ServiceInstanceSuspendentEvent. Consuming these events will allow you to handle certain situations gracefully in your BizTalk solution. For instance, when a mapping error occurs on a send or receive port, you could decide to send an e-mail to an administrator and automatically terminate the service instance. Listing 3 shows how to subscribe to a WMI event.

Example 3. Subscribing to a BizTalk WMI Event
using System.Management;

static public void ListenForSvcInstSuspendEvent()
        // Set up an event watcher and a handler for the
MSBTS_ServiceInstanceSuspendedEvent event
       ManagementEventWatcher watcher =
new ManagementEventWatcher( new ManagementScope("root\\MicrosoftBizTalkServer"),
new EventQuery("SELECT * FROM MSBTS_ServiceInstanceSuspendedEvent") );

        watcher.EventArrived += new EventArrivedEventHandler(MyEventHandler);

        // Start watching for MSBTS_ServiceInstanceSuspendedEvent events

        Console.WriteLine("Press enter to quit");
     catch (Exception ex)
        Console.WriteLine("Error: " + ex.Message);

  static public void MyEventHandler(object sender, EventArrivedEventArgs e)
     // Print out the service instance ID and error description upon receiving
     // of the suspend event
     Console.WriteLine("A MSBTS_ServiceInstanceSuspendEvent has occurred!");
     Console.WriteLine(string.Format("ServiceInstanceID: {0}",
     Console.WriteLine(string.Format("ErrorDescription: {0}",


- BizTalk Server 2009 : Administrative Tools (part 1) - BizTalk Administration Console, BTSTask
- Microsoft Dynamic GP 2010 : Understanding all of the financial information about an asset with Fixed Asset Details
- Microsoft Dynamic GP 2010 : Tracking Tangible Personal Property Tax information for Fixed Assets
- Managing Exchange Server 2010 : Archiving and compliancy (part 3) - Discovery, Litigation hold
- Managing Exchange Server 2010 : Archiving and compliancy (part 2) - Messaging Records Management
- Managing Exchange Server 2010 : Archiving and compliancy (part 1) - Exchange 2010 Archiving
- Managing Exchange Server 2010 : Role Based Access Control (RBAC)
- Active Directory Domain Services 2008 : Proactive Directory Performance Management (part 2) - Working with Windows System Resource Manager
- Active Directory Domain Services 2008 : Proactive Directory Performance Management (part 1) - Managing System Resources
- Microsoft Dynamic AX 2009 : Enterprise Portal - Enterprise Portal Development Tools, Developing Data Sets
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
programming4us programming4us
Popular tags
Video Tutorail Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Biztalk Exchange Server Microsoft LynC Server Microsoft Dynamic Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 Adobe Indesign Adobe Flash Professional Dreamweaver Adobe Illustrator Adobe After Effects Adobe Photoshop Adobe Fireworks Adobe Flash Catalyst Corel Painter X CorelDRAW X5 CorelDraw 10 QuarkXPress 8 windows Phone 7 windows Phone 8 BlackBerry Android Ipad Iphone iOS