How to get Windows Indexing Service state from code?

330 views Asked by At

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

Indexing status

1

There are 1 answers

0
Radek On BEST ANSWER

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.