Shutting down COM app from a command line

Discussion in 'ASP .Net' started by Larry Bud, Jul 30, 2007.

  1. Larry Bud

    Larry Bud Guest

    Not sure where else to post this.... One of our developers quit and
    I'm taking over stuff from him.

    He had a COM app that would lock files on occasion (yeah, thanks for
    leaving that in production instead of finding the real problem)...
    anyway, the "fix" was to shut down the com app when it would lock the
    file.

    Any way to do that from a command line?
    Larry Bud, Jul 30, 2007
    #1
    1. Advertising

  2. Larry Bud

    Aidy Guest

    What do you mean by "COM app". An EXE? A COM+ Application?

    "Larry Bud" <> wrote in message
    news:...
    > Not sure where else to post this.... One of our developers quit and
    > I'm taking over stuff from him.
    >
    > He had a COM app that would lock files on occasion (yeah, thanks for
    > leaving that in production instead of finding the real problem)...
    > anyway, the "fix" was to shut down the com app when it would lock the
    > file.
    >
    > Any way to do that from a command line?
    >
    Aidy, Jul 30, 2007
    #2
    1. Advertising

  3. Larry Bud

    Larry Bud Guest


    > "Larry Bud" <> wrote in message
    >
    > news:...
    >
    >
    >
    > > Not sure where else to post this.... One of our developers quit and
    > > I'm taking over stuff from him.

    >
    > > He had a COM app that would lock files on occasion (yeah, thanks for
    > > leaving that in production instead of finding the real problem)...
    > > anyway, the "fix" was to shut down the com app when it would lock the
    > > file.

    >
    > > Any way to do that from a command line?- Hide quoted text -


    On Jul 30, 10:50 am, "Aidy" <> wrote:
    > What do you mean by "COM app". An EXE? A COM+ Application?
    >


    Sorry.

    Yes, a COM+ Application.
    Larry Bud, Jul 30, 2007
    #3
  4. Larry Bud

    Aidy Guest

    You could script it or make a small app to do it;

    http://www.devx.com/vb2themax/Tip/19633

    "Larry Bud" <> wrote in message
    news:...
    >
    >> "Larry Bud" <> wrote in message
    >>
    >> news:...
    >>
    >>
    >>
    >> > Not sure where else to post this.... One of our developers quit and
    >> > I'm taking over stuff from him.

    >>
    >> > He had a COM app that would lock files on occasion (yeah, thanks for
    >> > leaving that in production instead of finding the real problem)...
    >> > anyway, the "fix" was to shut down the com app when it would lock the
    >> > file.

    >>
    >> > Any way to do that from a command line?- Hide quoted text -

    >
    > On Jul 30, 10:50 am, "Aidy" <> wrote:
    >> What do you mean by "COM app". An EXE? A COM+ Application?
    >>

    >
    > Sorry.
    >
    > Yes, a COM+ Application.
    >
    >
    Aidy, Jul 30, 2007
    #4
  5. Larry Bud

    Eric Guest

    using System;
    using System.Collections;
    using System.Collections.Specialized;
    using COMAdmin; // This needs a reference to the "COM+ Admin" dll on
    the COM tab

    namespace xxx
    {
    class ShutdownCom
    {
    #region Get COM+ Applications
    public StringCollection GetCOMApplications()
    {
    StringCollection collection = new StringCollection();
    try
    {
    ICOMAdminCatalog objAdmin;
    ICatalogCollection objCollection;

    objAdmin = (ICOMAdminCatalog) new
    COMAdmin.COMAdminCatalog();
    objCollection = (ICatalogCollection)
    objAdmin.GetCollection("Applications");
    objCollection.Populate();

    foreach(COMAdmin.COMAdminCatalogObject objApp in
    objCollection)
    {
    collection.Add(objApp.Name.ToString());
    // Console.WriteLine(objApp.Name.ToString());
    }
    }
    catch(Exception ex)
    {
    Console.WriteLine("Error: " + ex.Message);
    return null;
    }
    return collection;
    }
    #endregion

    #region Shutting Down COM+ Application
    public void ShutDownCOMApplication(string appName)
    {
    try
    {
    ICOMAdminCatalog objAdmin;
    ICatalogCollection objCollection;

    objAdmin = (ICOMAdminCatalog) new
    COMAdmin.COMAdminCatalog();
    objCollection = (ICatalogCollection)
    objAdmin.GetCollection("Applications");

    Console.WriteLine("Shutting down: " + appName);
    objAdmin.ShutdownApplication(appName);
    }
    catch(Exception ex)
    {
    Console.WriteLine("Unable to shutdown the application, err=" +
    ex.Message);
    }
    }
    #endregion


    [STAThread]
    static void Main(string[] args)
    {
    // create an instance of our class
    ShutdownCom shutdown = new ShutdownCom();

    // shutdown all applications that begin with ZC
    StringCollection appList = shutdown.GetCOMApplications();
    foreach (string appName in appList)
    {
    if (appName.ToUpper().StartsWith("ZC"))
    shutdown.ShutDownCOMApplication(appName);
    }
    }
    }
    }
    Eric, Jul 31, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Qm9zc29tYQ==?=

    Windows 98 SE freezes when shutting down.

    =?Utf-8?B?Qm9zc29tYQ==?=, Jun 26, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    572
    Eddie
    Jun 27, 2005
  2. rooster575
    Replies:
    1
    Views:
    360
    Lau Lei Cheong
    Jul 2, 2004
  3. J-T
    Replies:
    4
    Views:
    9,284
  4. J-T
    Replies:
    0
    Views:
    534
  5. Jack
    Replies:
    2
    Views:
    1,560
Loading...

Share This Page