Wrox Programmer Forums
|
VB Components Issues specific to components in VB.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Components section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 30th, 2004, 12:17 PM
Registered User
 
Join Date: Jan 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Starting COM+ Applications

I need to know how to programmatically stop and start a COM+ application. It doesn't necessarily need to be written in VB though. Can this be done? Anything special I need to take into consideration?

Thanks
 
Old January 30th, 2004, 02:38 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

What kind of application is (i.e. Windows server, service etc...)
Marco
 
Old February 2nd, 2004, 08:26 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

You can do this easily using the COM+ Admin dll. It can be done in VB or in a script language like VBS (which you can run using WSH). Here's example code:
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
hth
Phil
 
Old February 2nd, 2004, 11:44 AM
Registered User
 
Join Date: Jan 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks alot. This seems to be what I need.

 
Old September 2nd, 2004, 05:09 AM
Registered User
 
Join Date: Sep 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

is there any way to actually start and stop com+ packages on a different server through an IP address?

If any one can make changes to this script would be much appreciated:

 Dim oApplications 'As COMAdminCatalogCollection
    Dim oCatalog 'As COMAdminCatalog
    Dim oApp 'As COMAdminCatalogObject


    Set oCatalog = CreateObject("ComAdmin.COMAdminCatalog")
    Set oApplications = oCatalog.GetCollection("Applications")
    oApplications.Populate

    Wscript.Echo "Now Closing Tranzax Communications All Users Will Be Looged Off And Unable To Log In."
    For Each oApp In oApplications
        If oApp.Name = "Tranzax" Then
        Wscript.Echo "Shutting down " & oApp.Name, vbOKOnly + vbInformation
            Call oCatalog.ShutdownApplication(oApp.Name)

        End If
    Next 'oApp

    Wscript.Echo "Completed Shutdown Process Of Tranzax Now Exiting"

    Set oApp = Nothing
    Set oApplications = Nothing
    Set oCatalog = Nothing

 
Old September 2nd, 2004, 06:46 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

See http://msdn.microsoft.com/library/en...fRemoteWSH.asp for details of how to use remote scripting to run that script against a different server.

hth
Phil





Similar Threads
Thread Thread Starter Forum Replies Last Post
Access Starting dond Access 3 August 30th, 2007 10:02 PM
Just starting... lozbritt9 C++ Programming 1 March 10th, 2006 12:54 PM
Mysql Starting rajuru PHP Databases 2 September 9th, 2004 11:59 AM
Starting ASP .NET web applications stripytiger General .NET 6 August 30th, 2004 01:17 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.