You create an ISearchCatalog interface object by calling the Add method. You access a specific ISearchCatalog interface object by calling the Item property. Because ISearchCatalogs is a collection, you can access all ISearchCatalog interface objects using a for each loop, as in the following example, where objCatalog is the name you give to the ISearchCatalog interface object:
Option Explicit
On Error Resume Next
Dim objSearchAdmin, objSearchCatalog
Dim Prompt, Buttons, Title, Response
Set objSearchAdmin = CreateObject("Search.SearchAdmin.1")
'Add KMSampleCatalog1
objSearchAdmin.SearchServer.SearchCatalogs.Add("KMSampleCatalog1")
For Each objSearchCatalog in objSearchAdmin.SearchServer.SearchCatalogs
'Make the catalog searchable or unsearchable
Prompt = "Would you like to make " & objSearchCatalog.Name _
& "searchable?"
Buttons = vbYesNo + vbDefaultButton2 + vbExclamation + vbSystemModal
Title = "Search/Don't Search Catalog"
Response = MsgBox(Prompt, Buttons, Title)
if Response = vbYes then
objSearchCatalog.Enable
else
objSearchCatalog.Disable
end if
'Display the catalog properties
Wscript.Echo "Name: " & objSearchCatalog.Name
Wscript.Echo "Build Server: " & objSearchCatalog.BuildServer
Wscript.Echo "Search Server: " & objSearchCatalog.SearchServer
Wscript.Echo "Max result rows: " & objSearchCatalog.MaxResultRows
Wscript.Echo "Query timeout: " & objSearchCatalog.QueryTimeout _
& " (milliseconds)"
Wscript.Echo "Status: " & objSearchCatalog.Status
' See Accessing ICatalogProperties Interface Objects
Next
'Release objects
Set objSearchCatalog = Nothing
Set objSearchAdmin = Nothing