Search code examples
c#windowsvb.netwindows-searchindexing-service

How to get Windows Indexing Service state from code?


How to find, how to read Windows Indexing Service state (indexing state) from code? OS is Windows Server 2012 R2.

Indexing status


Solution

  • This can be done by using Microsoft.Search.Interop witch I get from here: https://www.nuget.org/packages/tlbimp-Microsoft.Search.Interop/

    Then it is easy using documentation from: https://learn.microsoft.com/en-us/windows/win32/api/searchapi/ne-searchapi-catalogstatus to get indexing status.

        Dim status As _CatalogStatus
        Dim reason As _CatalogPausedReason
        Dim manager As CSearchManager = New CSearchManager()
        Dim catalogManager As ISearchCatalogManager = manager.GetCatalog("SystemIndex")
        catalogManager.GetCatalogStatus(status, reason)
    

    All I did on Windows Server 2012 R2.