Removing components from a COM+ application VBScript

Discussion in 'Scripting' started by Sean Mahan, Feb 11, 2004.

  1. Sean Mahan

    Sean Mahan Guest

    Here is the snippet that I am having trouble with.
    I can easily create my Application and add components
    to it but when I try and remove it I get (usually) object
    does not support that method.

    Set cat = CreateObject("COMAdmin.COMAdminCatalog.1")
    Set apps = cato.GetCollection("Applications")
    apps.Populate
    Set comps = apps.GetCollection("Components", AppID)
    comps.Populate
    for i = 0 to comps.Count
    If comps(i).CLSID = Up1Clsid Then
    comps.Remove(comps(i))
    End If
    Next
    comps.SaveChanges
    appls.SaveChanges

    The actual goal of the script in it's entirety is to
    remove an old component and then add a newer version of
    that component. I'm trying to automate the deployment of
    an application. This is the last manual step that our
    webmasters need to do and I'd like for them not to do it
    anymore.

    Thanks in advance.
     
    Sean Mahan, Feb 11, 2004
    #1
    1. Advertisements

  2. Sean Mahan

    JStinebaugh

    Joined:
    May 23, 2014
    Messages:
    1
    Likes Received:
    0
    I'm guessing you found a way around this, but for anyone looking to remove/uninstall a component the above code will work except for the comps.Remove(comps(i)) line. You need to pass in the index of the component you want to remove. The correct line would be comps.Remove(i).

    Set cat = CreateObject("COMAdmin.COMAdminCatalog.1")
    Set apps = cato.GetCollection("Applications")
    apps.Populate
    Set comps = apps.GetCollection("Components", AppID)
    comps.Populate
    for i = 0 to comps.Count
    If comps(i).CLSID = Up1Clsid Then
    comps.Remove(i)
    End If
    Next
    comps.SaveChanges

    Hope this helps anyone else looking for an answer to this.
     
    JStinebaugh, May 23, 2014
    #2
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.