Freigeben über


How To : VB Script to Remove the Machine Names from COM+ catalog.

We had a lot of remote servers configured in Component Services. Some of the servers later got decommissioned. Now when we try to click on the machine name nodes in Component Services it hangs and does not respond. We ran the VB script below to remove the machine name nodes from COM+ catalog.You need to be the local administrator on the machine to be able to run the script below:

 

' Script to delete Machine names from COM+ catalog
' ===========================================================

Dim catalog 'As COMAdmin.COMAdminCatalog
Dim Machines 'As COMAdminCatalogCollection

Set Catalog = CreateObject("COMAdmin.COMAdminCatalog")

'Collect input from user
Dim sMachine
sMachine = Inputbox("Enter Machine name to be deleted (case sensitive):","Delete Machine name", "My Computer")  
 If sMachine="" Then
    MsgBox"Invalid input, restart the program"
    WScript.Quit
 End If
If sMachine="My Computer" Then
   msgbox ("You cannot delete My Computer")
   WScript.Quit
End If
 

'Get the Machines collection in COM+ catalog
 Set Machines = Catalog.GetCollection("ComputerList")
 Machines.Populate

'Get the count of the number of objects
 MsgBox("No. of Machine names found : " & Machines.Count)

'Get the correct machine name
 counter = 0
 Dim MachineObj 'As COMAdminCatalogObject
 For Each MachineObj in Machines
    If MachineObj.Name=sMachine Then
             MsgBox(MachineObj.Name)
             Exit For            
    End If
    counter = counter +1
 Next

'Delete the machine name
If counter < machines.count Then
Dim answer
    answer = Msgbox("Are you sure you want to delete: " & sMachine, vbYesNo, "Confirm Deletion?")
    If answer=vbYes Then
       Machines.Remove(counter)
       Machines.SaveChanges
    End If
Else
   Msgbox "'" & sMachine & "' not found in the COM+ catalog.", vbOkOnly,"Machine Not Found"
End If