COM+ application starting and stopping

by Hari Mukkapati 26. June 2009 04:12

COM+ application starting and stopping can be done easily using the COM+ Admin dll.  It can be done using VB or in a script language like VBS (which you can run using WSH).  Here's example code:

On Error Resume Next 
    ' if VB add a reference to COM+ 1.0 Admin Type Library. 
    ' if VBS just declare this object without a type 
    Dim oCatalog As COMAdmin.COMAdminCatalog 
    Dim sName As String 
    Set oCatalog = CreateObject("COMAdmin.COMAdminCatalog") 
  
    sName = "the package name goes here"    
    oCatalog.ShutdownApplication sName 
    
    ' to start the app use this syntax 
    'oCatalog.StartApplication sName 
    
    If Err.Number = 0 Then 
        MsgBox sName & " has been shut down.", vbOKOnly + vbInformation 
    Else 
        Const cMsg = "Error 0x#ERR# trying to shut down #APP#. (#DESC#.)" 
        Dim sMsg 
        sMsg = Replace(cMsg, "#ERR#", Hex(Err.Number), 1, 1) 
        sMsg = Replace(sMsg, "#APP#", sName, 1, 1) 
        sMsg = Replace(sMsg, "#DESC#", Err.Description, 1, 1) 
        MsgBox sMsg, vbOKOnly + vbInformation 
        Err.Clear 
    End If 
    Set oCatalog = Nothing 
del.icio.us Tags: ,,

Tags: , ,

Comments are closed

Mukkapati.com

About the author

Hari Mukkapati

Month List

Calendar

<<  July 2010  >>
MoTuWeThFrSaSu
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

View posts in large calendar